Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

直接暴力

Posted by Geekdj1988 at 2012-06-01 17:59:28 on Problem 2406
#include<cstdio>
#include<cstring>

char str[1000000];
int main()
{
    while(scanf("%s",str),str[0]!='.')
    {
	int i,j=0;
	int len = strlen(str);
	for(i=1;j!=len && i<len;i++)
	    if(len%i == 0)
		for(j=i;j<len && strncmp(str,str+j,i)==0;j+=i);
	printf("%d\n",i==len? 1:len/(i-1));
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator