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 yueyibo at 2016-11-13 16:43:30 on Problem 2406
注意一下aaac和aabaabaa这两种情况
#include<cstdio>
#include<cstring> 
using namespace std;
int i,j,len;
char s[1000010];

void getnext(){
	i=1,j=0;
	while(i<len){
		if(s[i]==s[j]){
			i=i+1;
			j=j+1;
		}
		else{
			j=0;
			i++;
		}
	}
}
int main(){
	while(scanf("%s",&s)!=EOF){
		if(s[0]=='.'){
			return 0;
		}
		else{
			len=strlen(s);
		}
		getnext();
		if(len%(i-j)!=0){
			printf("1\n");
		}
		else
		printf("%d\n",len/(i-j));
	}
} 

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