- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int i;
- int n;
- int a,b,c;
- string s;
- cout<<"please input the string"<<endl;
- cin>>s;
- n=s.length();
- for(i=1;i<=n;i++)
- {
- if(n%i==0)
- {
- a=n/i;
- for(b=1;b<=i;b++)
- {
- for(c=1;c<=a-1;c++)
- {
- if(s[b-1]!=s[b+c*i-1])
- {
- goto here;
- }
- }
- }
- cout<<i<<endl;
- goto here1;
- }
- here:
- ;
- }
- here1:
- ;
- return 0;
- }
算法竞赛入门经典3.4 周期串UVa455
最新推荐文章于 2020-03-28 18:34:49 发布