标签:print style lin fine org put targe one 循环
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 50627 | Accepted: 21118 |
Description
Input
Output
Sample Input
abcd aaaa ababab .
Sample Output
1 4 3
Hint
Source
1 #include <algorithm> 2 #include <cstring> 3 #include <cstdio> 4 5 using namespace std; 6 7 const int N(2333333); 8 int ans,len,p[N]; 9 char s[N]; 10 11 inline void Get_next() 12 { 13 for(int i=2,j=0;i<=len;i++) 14 { 15 for(;s[i]!=s[j+1]&&j>0;) j=p[j]; 16 if(s[i]==s[j+1]) j++; 17 p[i]=j; 18 } 19 } 20 21 int main() 22 { 23 for(scanf("%s",s+1);s[1]!=‘.‘;scanf("%s",s+1)) 24 { 25 memset(p,0,sizeof(p)); 26 len=strlen(s+1); 27 Get_next(); 28 int tmp=len-p[len]; 29 if(len%tmp) puts("1"); 30 else printf("%d\n",len/tmp); 31 } 32 return 0; 33 }
标签:print style lin fine org put targe one 循环
原文地址:http://www.cnblogs.com/Shy-key/p/7382656.html