| ||||||||||
| 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 | |||||||||
直接暴力竟然只有300ms不到,这题真是太暴力了,付暴力代码#include<stdio.h>
#include<string.h>
char temp[1005000]={0};
int main()
{
int i=0,N=0,ans=0,j=0;
while(scanf("%s",&temp))
{
N=strlen(temp);
if(N==1&&temp[0]=='.')
break;
for(i=1;i<=N;i++)
{
if(N%i==0)
{
for(j=i;j<N;j+=i)
{
if(strncmp(temp,temp+j,i))
{
break;
}
}
if(j==N)
{
ans=N/i;
break;
}
}
}
printf("%d\n",ans);
}
}
再次感叹一下库函数的威力
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator