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

Re:G++ AC 0MS,C++ TLE。。。哪位指教下这是什么原因?

Posted by TSERROF at 2013-01-03 21:58:06 on Problem 1152
In Reply To:Re:G++ AC 0MS,C++ TLE。。。哪位指教下这是什么原因? Posted by:TSERROF at 2013-01-03 21:56:18
数组开小点就0ms了。。。。囧
#include <cstdio>
#include <cstring>
#define  MAXN 30001
char num[MAXN];
int main()
{
	while(scanf("%s",num)!=EOF)
	{
		int sum=0,n=-1,temp;
		for(unsigned int i=0;i<strlen(num);++i)
		{
			if(num[i]<='9' && num[i]>='0')temp=num[i]-'0';
			else if(num[i]>='A' && num[i]<='Z')temp=num[i]-'A'+10;
			else temp=num[i]-'a'+36;
			sum+=temp;
			if(temp>n)n=temp;
		}
		for(;n<=62;++n)
			if(sum%n==0)
				break;
		if(n>=62)printf("such number is impossible!\n");
		else printf("%d\n",n+1);
	}
	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