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 hheq121 at 2009-04-23 09:52:48 on Problem 1152
#include<iostream>
using namespace std;
char p[50000];
int main()
{
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	int i;
	while(gets(p))
	{
		int max=0;int sum=0;int a,b,c;
		for(i=0;i<strlen(p);i++)
		{
			if(p[i]<='9')
			{
				a=p[i]-'0';
				if(max<a)
					max=a;
				sum=sum+a;
				continue;
			}		
			if(p[i]<='Z')
			{
				b=p[i]-'A'+10;
				if(max<b)
					max=b;
				sum=sum+b;
				continue;
			
			}
			if(p[i]<='z')
			{
				c=p[i]-'a'+36;
				if(max<c)
					max=c;
				sum=sum+c;
				continue;
			}			
		}
		if(sum==0)
		{printf("such number is impossible!\n");continue;}
		for(i=max+1;i<=62;i++)
		{
			if(sum%(i-1)==0)
			{printf("%d\n",i);break;}
		}
		if(i>62)
			printf("such number is impossible!\n");

	}
	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