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 2004551304 at 2006-08-10 16:36:54 on Problem 2406
#include<iostream>
#include<cstring>
#define MAX 1000001
using namespace std;
int main()
{

	char s[MAX];
    long i,j,n,count,precount=0;  //前一个次数,与当前次数比较,求出最大次数
	scanf("%s",&s);
	while(s[0]!='.')
	{
		bool flag[MAX]={0};   //
		precount=0;
		n=strlen(s);
	
		for(i=0;i<n;i++)
		{
			count=0;  //记录当前字母的重复次数

			while((flag[i]==1)&&(i<n))    //若已经搜索过,跳过
				i++;
			if(i==n)   //到末尾,跳出循环
				break;

			for(j=i;j<n;j++)
			{
              if(s[j]==s[i])
			  {
				  count++;
				  flag[j]=1;
			  }
			}//for j
			
			
			if(count>precount)
			    	   precount=count;   
		
		


		}//for i

		
        cout<<precount<<endl;
        scanf("%s",&s);
	}//while


	return 1;
}

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