| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
甩发代码,其实不是那么麻烦,代码多了点,直接模拟比较就可以了#include <stdio.h>
#include <string.h>
typedef struct tagDigit{
int number;
char d[3][4];
tagDigit(){}
tagDigit(int number,char d[3][4]){
this->number=number;
for(int i=0;i<3;i++){
for(int j=0;j<4;j++){
this->d[i][j]=d[i][j];
}
}
}
}Digit;
const int _MAXN=30;
Digit Num[10];
char digit[3][_MAXN];
int ans1,ans2,ans3,ans4;
void init(){
char tmp0[3][4]={" _ ","| |","|_|"};
Num[0]=Digit(0,tmp0);
char tmp1[3][4]={" "," |"," |"};
Num[1]=Digit(1,tmp1);
char tmp2[3][4]={" _ "," _|","|_ "};
Num[2]=Digit(2,tmp2);
char tmp3[3][4]={" _ "," _|"," _|"};
Num[3]=Digit(3,tmp3);
char tmp4[3][4]={" ","|_|"," |"};
Num[4]=Digit(4,tmp4);
char tmp5[3][4]={" _ ","|_ "," _|"};
Num[5]=Digit(5,tmp5);
char tmp6[3][4]={" _ ","|_ ","|_|"};
Num[6]=Digit(6,tmp6);
char tmp7[3][4]={" _ "," |"," |"};
Num[7]=Digit(7,tmp7);
char tmp8[3][4]={" _ ","|_|","|_|"};
Num[8]=Digit(8,tmp8);
char tmp9[3][4]={" _ ","|_|"," _|"};
Num[9]=Digit(9,tmp9);
}
bool judge(int g1,int g2,int g3,int g4,int flag){
bool ok=true;
int G[5]={0,g1,g2,g3,g4};
int s=1;
for(int L=(flag==1? 0:13);L<(flag==1? 10:23);L+=3,s++){
for(int i=0;i<3;i++){
for(int j=L;j<L+3;j++){
if(Num[G[s]].d[i][j-L]==' '&&digit[i][j]!=' '){
ok=false;
goto F;
}
}
}
}
F:;
return ok;
}
int main(){
init();
int N;
for(scanf("%d",&N),getchar();N--;){
//scan
for(int i=0;i<3;i++){
gets(digit[i]);
}
ans1=ans2=ans3=ans4=0;
//work
int sum=0;
for(int L1=0;L1<3;L1++){
int top=L1==2? 4:10;
for(int L2=0;L2<top;L2++){
for(int L3=0;L3<6;L3++){
for(int L4=0;L4<10;L4++){
int timeNow=(L1*10+L2)*60+L3*10+L4;
int timePre=(timeNow-15+1440)%1440;
int l1,l2,l3,l4;
int t1=timePre/60;
int t2=timePre%60;
l1=t1/10;
l2=t1%10;
l3=t2/10;
l4=t2%10;
if(true==judge(L1,L2,L3,L4,1)&&true==judge(l1,l2,l3,l4,2)){
sum++;
if(sum>1){
goto E;
}
ans1=L1,ans2=L2,ans3=L3,ans4=L4;
}
}
}
}
}
E:;
if(sum>1){
puts("Not Sure");
}else{
printf("%d%d%d%d\n",ans1,ans2,ans3,ans4);
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator