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

哪位大哥帮看小弟看一下为什么总WA

Posted by sunyuanshuai at 2009-04-19 21:49:24 on Problem 1152
In Reply To:Please give me some sample tests. Thanks! Posted by:yogafrank at 2007-09-15 19:27:57
#include<iostream>
#include<string>
using namespace std;

int main()
{
	string str;
	while(getline(cin,str))
	{
		if(str=="0")
		{
			cout<<2<<endl;
			continue;
		}
		int i,sum=0,max=0;
		for(i=0;i<str.length();i++)
		{
			if(str[i]>='0'&&str[i]<='9')
			{
				if(str[i]-'0'>max)
					max=str[i]-'0';
				sum+=str[i]-'0';
			}
			else if(str[i]>='A'&&str[i]<='Z')
			{
				if(str[i]-55>max)
					max=str[i]-55;
				sum+=str[i]-55;
			}
			else if(str[i]>='a'&&str[i]<='z')
			{
				if(str[i]-61>max)
					max=str[i]-61;
				sum+=str[i]-61;
			}
		}
		for(i=max;i<=61;i++)
		{
			if(sum%i==0)
			{
				cout<<(i+1)<<endl;
				break;
			}
		}
		if(i>62)
			cout<<"such number is impossible!"<<endl;
	}
	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