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<iostream> #include<string.h> using namespace std; int main() { char str[1000001]; while(cin>>str&&strcmp(str,".")!=0) { int count=0; char*p=str; int len=strlen(str); for(int i=2;i<=1000;i++) { while(len%i==0) { char*q[i]; int l=0,k=0; for(int j=0;j<i;j++) q[j]=&str[j*(len/i)]; while(l==0&&k<len/i) { for(int j=0;j<i-1;j++) {if(*q[j]++!=*q[j+1]) {l=1;break;} } if(l==1)break; q[i-1]++; k++; } if(k==len/i&&l==0) {count+=i; memmove(str,str,len/i); len=len/i; } else break; } } if(count==0)cout<<1<<endl; else cout<<count<<endl; } getchar(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator