1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| #include <stdio.h> #include <string.h> char baka[6][33]={{1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,0},{2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63,0},{4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39,44,45,46,47,52,53,54,55,60,61,62,63,0},{8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,56,57,58,59,60,61,62,63,0},{16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0},{32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,0}}; int busu[1000]={0}; int main (void) { int p=0,i=0; for(int n=0;;n++) { scanf("%d",&busu[n]); if(busu[n]==0) break; i=busu[n]-1; baka[i][32]=9; //printf("%d\n",baka[i][32]); //printf("%d\n",busu[n]); } for(int n=0;;n++) { if(busu[n]==0) break; p=busu[n]-1; for(int x=0;x<6;x++) { if(baka[x][32]!=9) { for(int m=0;m<32;m++) { for(int y=0;y<32;y++) { if(baka[p][y]==baka[x][m]) baka[p][y]=0; } } } }/* for(int y=0;y<32;y++) { printf("%d,",(baka[p][y])); } putchar('\n');*/ } for(int x=0;x<6;x++) { if(baka[x][32]!=9) { memset(baka[x],0,32); } } for(int n=0;;n++) { if(busu[n]==0) break; p=busu[n]-1; for(int x=0;x<6;x++) { if(busu[1]!=0) { if(baka[x][32]==9&&x!=p) { for(int m=0;m<32;m++) { for(int y=0;y<32;y++) { if(baka[p][y]==baka[x][m]&&baka[p][y]!=0) { printf("%d\n",baka[p][y]); return 0; } } } } } else { if(baka[x][32]==9) { for(int m=0;m<32;m++) { for(int y=0;y<32;y++) { if(baka[p][y]==baka[x][m]&&baka[p][y]!=0) { printf("%d\n",baka[p][y]); return 0; } } } } } }/* for(int y=0;y<32;y++) { printf("%d,",(baka[p][y])); } putchar('\n');*/ } }
|