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

RTE...55555555555555555555

Posted by 778273063084733 at 2007-08-19 19:19:06 on Problem 2406
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int i,j;
	long l,next[1000000];
	char s[1000000];
	scanf("%s",s);
	while(s[0]!='.'||s[1])
	{
		l=strlen(s);
		i=0;j=-1;next[0]=-1;
		while(i<l)
		{
			if(j==-1||s[i]==s[j]){i++;j++;next[i]=j;}
			else j=next[j];
		}
		if(s[l-1]!=s[next[l-1]]) cout<<1;
		else cout<<l/(l-next[l-1]-1);
		cout<<endl;
		scanf("%s",s);
	}
	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