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

这题好阴,9,3,7 ID是从后往前开始乘的!白WA一次

Posted by long1897 at 2014-06-14 21:22:22 on Problem 2498
Memory: 144K  Time: 110MS 
Language: C++  Result: Accepted 
•Source Code
#include<iostream>
#include<string>
using namespace std;
int prime[3]={9,3,7};
int main(){
	char s[10]={'\0'};
	int n,count=0,sum,j,flag,index;   
	scanf("%d",&n);
	while(count!=n){
		sum=j=0;
		scanf("%s",s);
		for(int i=strlen(s)-1;i>=0;i--)
		{
			if(s[i]=='?')
			{
				index=i;
				flag=j;
			}
			else
				sum+=(s[i]-48)*prime[j];
			if(j==2)
				j=0;
			else
				j++;
		}
		for(int i=0;i<10;i++)
			if((sum+prime[flag]*i)%10==0)
			{
				s[index]=static_cast<char>(i+48);
				break;
			}
		printf("Scenario #%d:\n%s\n\n",++count,s);
		memset(s,'\0',sizeof(s));
	}
	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