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

帮忙: WA:没有使用KMP算法,但是就查不出哪里有错误! 一直WA!

Posted by zhenly at 2008-08-25 14:13:49 on Problem 2406
#include<stdio.h>
#include<string.h>
void main()
{
	int len,l,b,i,t;
	char s[1000000];
	scanf("%s",s);
	while(strcmp(s,".")!=0)
	{
		len=strlen(s);
		for(l=1;l<=len;l++)
		{
			if(len%l!=0)
				continue;
			for(b=0;b+l<len;b+=l)
			{
				i=0;t=1;
				while(i<l)
				{
					if(s[b+i]!=s[b+l+i]) 
						t=0;
					i++;
				}
				if(t!=1)
				break;
			}
			if(b+l>=len)
				break;
		}
		//printf("%d\n",l);
		printf("%d\n",len/l);
		scanf("%s",s);
	}
}

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