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 yescrystal at 2006-08-15 05:25:37 on Problem 2190
In Reply To:不好意思 自己发现一处严重错误 改后AC了 呵呵~ Posted by:yescrystal at 2006-08-15 05:08:17
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string ISBN;
	cin >> ISBN;
	int index = ISBN.find("?");
	int all=0, i, j, remainder=0, ans=-1;
	for(j = 10,i=0; i<ISBN.size(); i++,j--) //j代表要乘的倍数
	{
		if(i!=index)
		{
			if(ISBN[i]=='X' && i==9) all+=10; 
			else all += int(ISBN[i]-'0')*j;
		}
	}
	remainder = (11-all%11)%11;
	for(i=0;i<10; i++)
	{
		if((i*(10-index)-remainder)%11 == 0)
		{ ans = i;  break;	}
	}
	if(index == 9 && remainder==10) 		cout << "X\n";
	else cout << ans << 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