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 wb_jerry at 2009-07-27 19:58:11 on Problem 2406
Source Code

Problem: 2406  User: wb_jerry 
Memory: N/A  Time: N/A 
Language: G++  Result: Wrong Answer 

Source Code 
#include <iostream>
#include <cstring>
using namespace std;
#include <stdio.h>
const int len=1000010;
string ifexit=".";
int p[len+1];
char s[len+1];
int main()
{	
	while(scanf("%s",&s))
	{
		if(s==ifexit) break;
		int i,k,m=strlen(s);
		p[1]=0;
		k=0;
		for(i=2;i<=m;i++)
		{
			while(k>0&&s[k]!=s[i-1])	
				k=p[k];
			if(s[k]==s[i-1])
				k=k+1;
			p[i]=k;
		}
**********************************************************************
                k=m;
		i=1;		
                while(p[k]!=0&&(3*p[k]>=2*k||2*p[k]==k))
		{
			k=p[k];
			i++;
		}
		cout<<i<<endl;
**********************************************************************
	}
	return 0;
}

我测试的数据都没什么问题啊,改成len/(len-next[len])后就AC了,是哪里没考虑到么?
那位同学能帮我看下两条线中间的部分有什么问题么

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