标签:des style blog http java color
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1248 Accepted Submission(s): 486
1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <string.h> 5 #include <set> 6 using namespace std; 7 set<string>ss; 8 void make(char a[],int x,int l) 9 { 10 char b[150]; 11 int i; 12 for(i=0; i<l; i++) 13 b[i]=a[x+i>=l?x+i-l:x+i]; 14 b[i]=‘\0‘; 15 ss.insert(b); 16 } 17 void moremin(char a[]) 18 { 19 int len=strlen(a); 20 int i,j,k,t; 21 k=i=0; 22 j=1; 23 while(i<len&&j<len&&k<len) 24 { 25 int t=a[i+k>=len?i+k-len:i+k]-a[j+k>=len?j+k-len:j+k]; 26 if(!t)k++; 27 else 28 { 29 if(t>0) i+=k+1; 30 else j+=k+1; 31 if(i==j)j++; 32 k=0; 33 } 34 } 35 make(a,(i>j?j:i),len); 36 } 37 int main() 38 { 39 int n; 40 char a[150]; 41 while(~scanf("%d",&n)) 42 { 43 ss.clear(); 44 while(n--) 45 { 46 scanf("%s",a); 47 moremin(a); 48 } 49 cout<<ss.size()<<endl; 50 } 51 }
hdu 2609 How many 最小表示法,布布扣,bubuko.com
标签:des style blog http java color
原文地址:http://www.cnblogs.com/ERKE/p/3832893.html