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 liyunyu at 2009-08-11 14:12:40 on Problem 2406
#include <iostream>
#include <stdlib.h>
#include <Cstring>
using namespace std;

int main ()
{
	char s1[100000];
	while (scanf("%s",&s1))
	{
		if(strcmp(s1,".")==0)
			break;
		int n=strlen(s1);
		int i=0 , j=1,k=1;
		while (j<n)
		{			
			if(s1[j]!=s1[i])
			{			
				j++;i=0;
				k=j;
			}
			else if(s1[i]==s1[j])
			{
				i++;j++;
			}
		}
		if(n%k == 0)
		   cout << n/k << endl;
		else cout << "1" <<endl;
	}
	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