题目链接: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[10]={490,288,242,434,312,410,474,290,506,442}; int temp; char ch[50]; int a[4],b[4]; int main() { int i,j,x,y,figure,group,Case=0,_i; //freopen("in.txt","r",stdin); scanf("%d",&group);gets(ch); while(group--){ mst(a,0);mst(b,0); for(i=0; i<3; ++i){ _i=0; gets(ch); for(j=0; j<12; ++j){ if(ch[_i++]!=‘ ‘){ a[j/3]|=1<<(i*3+j%3); } } ++_i; for(j=0; j<12; ++j){ if(ch[_i++]!=‘ ‘){ b[j/3]|=1<<(i*3+j%3); } } } int index=0; int ansh,ansm; for(i=0; i<1440; ++i){ int j=(i-15+1440)%1440; int h1=i/60; int m1=i%60; int h2=j/60; int m2=j%60; if((num[h1/10]&a[0])!=a[0]) continue; if(int(num[h1%10]&a[1])!=a[1]) continue; if(int(num[m1/10]&a[2])!=a[2]) continue; //cout<<1<<endl; if((num[m1%10]&a[3])!=a[3]) continue; if((num[h2/10]&b[0])!=b[0]) continue; if((num[h2%10]&b[1])!=b[1]) continue; if((num[m2/10]&b[2])!=b[2]) continue; if((num[m2%10]&b[3])!=b[3]) continue; if(++index>1) break; ansh=h1;ansm=m1; } if(index>1) printf("Not Sure\n"); else printf("%d%d%d%d\n",ansh/10,ansh%10,ansm/10,ansm%10); } return 0; }
参考:传送门
时间: 2024-10-12 16:43:38