题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=13175

题目关键:将0~9十个数转换为二进制数进行枚举比较

int num[10]={490,288,242,434,312,410,474,290,506,442};

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
#define Min(x,y) (x<y?x:y)
#define Max(x,y) (x>y?x:y)
using namespace std;
#define gamma 0.5772156649015328606065120 //欧拉常数
#define MOD 100000007
#define inf 0x3f3f3f3f
#define N 105
#define maxn 10001000
typedef long long LL;
typedef pair<int,int> PII; int num[]={,,,,,,,,,};
int temp;
char ch[];
int a[],b[]; int main()
{
int i,j,x,y,figure,group,Case=,_i;
//freopen("in.txt","r",stdin);
scanf("%d",&group);gets(ch);
while(group--){
mst(a,);mst(b,);
for(i=; i<; ++i){
_i=;
gets(ch);
for(j=; j<; ++j){
if(ch[_i++]!=' '){
a[j/]|=<<(i*+j%);
}
}
++_i;
for(j=; j<; ++j){
if(ch[_i++]!=' '){
b[j/]|=<<(i*+j%);
}
}
}
int index=;
int ansh,ansm;
for(i=; i<; ++i){
int j=(i-+)%;
int h1=i/;
int m1=i%;
int h2=j/;
int m2=j%;
if((num[h1/]&a[])!=a[])
continue;
if(int(num[h1%]&a[])!=a[])
continue;
if(int(num[m1/]&a[])!=a[])
continue;
//cout<<1<<endl;
if((num[m1%]&a[])!=a[])
continue;
if((num[h2/]&b[])!=b[])
continue;
if((num[h2%]&b[])!=b[])
continue;
if((num[m2/]&b[])!=b[])
continue;
if((num[m2%]&b[])!=b[])
continue;
if(++index>) break;
ansh=h1;ansm=m1;
}
if(index>) printf("Not Sure\n");
else printf("%d%d%d%d\n",ansh/,ansh%,ansm/,ansm%);
}
return ;
}

参考:传送门

05-11 21:59