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 Zain at 2005-07-22 10:01:42 on Problem 2498
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int max,T,n,i,j,flag,ans,k=1;
	string s;
	cin>>T;
	while(T--){
	    cin>>s;
		for(i=0;i<s.length();++i){
			if(s[i]=='?'){
				ans=i;
				break;
			} 
		}                      
		if(s.length()%3==1)   flag=9;
		else if(s.length()%3==2)  flag=3;
		else flag=7;                          
		for(j=0;j<10;++j){
		    max=0;
			s[ans]=j+48; 
			for(i=0;i<s.length();++i){
			    max+=(int(s[i]-48))*flag;     
				if(flag==9)  flag=7;
				else if(flag==7)  flag=3;
				else flag=9;
			}
			if(max%10==0)   break;    
		}
	    cout<<"Scenario #"<<k++<<':'<<endl;
        if(max%10==0)  cout<<s<<endl;
		cout<<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