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 quanjianan at 2006-05-28 12:02:23 on Problem 2498
#include<iostream>
using namespace std;

int main()
{
	char c[7];
	int n,i,t,k,j;
	long int sum;
	cin>>n;
	j=1;
	while (n--)
	{
		cin>>c;
		sum=0;
		k=strlen(c);
	    for (i=0;i<=k;i++)
		{
			if (c[i]=='?') t=i;
		}
		
		for (i=0;i<k;i++)
		{
			if ((i%3==0)&&(i!=t)) sum+=(c[i]-48)*9;
			else if ((i%3==1)&&(i!=t)) sum+=(c[i]-48)*7;
			else if ((i%3==2)&&(i!=t)) sum+=(c[i]-48)*3;
		}
		switch (t%3)
		{
			case 0:
				for (i=9;i>=0;i--)
					if ((sum+i*9)%10==0) break;
				break;
			case 1:
                for (i=9;i>=0;i--)
					if ((sum+i*7)%10==0) break;
				break;
			case 2:
                for (i=9;i>=0;i--)
					if ((sum+i*3)%10==0) break;
		}
		c[t]=i+48;
		cout<<"Scenario #"<<j<<":"<<endl;
        cout<<c<<endl<<endl;
		j++;
		
	}
	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