//\\__ hr1212 __//\\
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
int n,m;
vi v;
int main(){
int r,k,i,c=0,x=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;string p;
while(1){
v.clear();
cin>>p;
if(p==".")
break;
n=p.size();
f(i,1,n){
if(p[i]==p[0])
v.pb(i);
}
x=0;
if(v.size()!=0)
l=v[x++];
else
l=n;
while(l<n && x<=v.size()){
c=0;
if(n%l!=0){
if(x==v.size()){
l=n;
break;
}
l=v[x++];
continue;
}
for(j=l;j<n;j+=l){
i=0;
f(k,j,j+l){
if(p[k]!=p[i++]){
c=1;
break;
}
}
if(i!=l)
c=1;
if(c)
break;
}
if(x==v.size() && c){
l=n;
break;
}
if(c)
l=v[x++];
else
break;
}
pi(n/l);
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
int n,m;
vi v;
int main(){
int r,k,i,c=0,x=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;string p;
while(1){
v.clear();
cin>>p;
if(p==".")
break;
n=p.size();
f(i,1,n){
if(p[i]==p[0])
v.pb(i);
}
x=0;
if(v.size()!=0)
l=v[x++];
else
l=n;
while(l<n && x<=v.size()){
c=0;
if(n%l!=0){
if(x==v.size()){
l=n;
break;
}
l=v[x++];
continue;
}
for(j=l;j<n;j+=l){
i=0;
f(k,j,j+l){
if(p[k]!=p[i++]){
c=1;
break;
}
}
if(i!=l)
c=1;
if(c)
break;
}
if(x==v.size() && c){
l=n;
break;
}
if(c)
l=v[x++];
else
break;
}
pi(n/l);
}
return 0;
}
No comments:
Post a Comment