标签:
代码:
#include <iostream> #include <cstdio> using namespace std; typedef struct snow{ int a[6]; snow *next; }; snow *s[100000]; int fin(int b[],int sum){ snow *p; p=s[sum]->next; while(p){ for(int i=0;i<6;i++){ int j; if(b[i]==p->a[0]){ for(j=1;j<6;j++){ if(b[i+j]%6!=p->a[j]){ break; } } if(j==6){ return 1; } for(j=1;j<6;j++){ if(b[((i-j%6+6)%6)]!=p->a[j]){ break; } } if(j==6){ return 1; } } } p=p->next; } p=new snow; for(int i=0;i<6;i++){ p->a[i]=b[i]; } p->next=s[sum]->next; s[sum]->next=p; return 0; } int main() { int n; int t; int b[6]; int sum; int flag; scanf("%d",&n); for(int i=0;i<100000;i++){ s[i]=new snow; s[i]->next=NULL; } while(n--){ scanf("%d",&t); flag=0; for(int i=0;i<t;i++){ sum=0; for(int j=0;j<6;j++){ scanf("%d",&b[j]); sum+=b[j]; } sum%=100000; if(!flag){ if(fin(b,sum)){ flag=1; } } } if(flag){ printf("Twin snowflakes found.\n"); }else{ printf("No two snowflakes are alike.\n"); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/TWS-YIFEI/p/5811394.html