HDOJ 2714 HDU 2714 ISBN ACM 2714 IN HDU
4798 ワード
MiYuオリジナル、転帖は明記してください:転載は______________白い家 から
タイトルアドレス:
http://acm.hdu.edu.cn/showproblem.php?pid=2714
タイトルの説明:
ISBNTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 566 Accepted Submission(s): 172
Problem Description
Farmer John's cows enjoy reading books, and FJ has discovered that his cows produce more milk when they read books of a somewhat intellectual nature. He decides to update the barn library to replace all of the cheap romance novels with textbooks on algorithms and mathematics. Unfortunately, a shipment of these new books has fallen in the mud and their ISBN numbers are now hard to read.
An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. To verify that an ISBN number is correct, you calculate a sum that is 10 times the first digit plus 9 times the second digit plus 8 times the third digit ... all the way until you add 1 times the last digit. If the final number leaves no remainder when divided by 11, the code is a valid ISBN.
For example 0201103311 is a valid ISBN, since
10*0 + 9*2 + 8*0 + 7*1 + 6*1 + 5*0 + 4*3 + 3*3 + 2*1 + 1*1 = 55.
Each of the first nine digits can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number.
Your task is to fill in the missing digit from a given ISBN number where the missing digit is represented as '?'.
Input
* Line 1: A single line with a ten digit ISBN number that contains '?' in a single position
Output
* Line 1: The missing digit (0..9 or X). Output -1 if there is no acceptable digit for the position marked '?' that gives a valid ISBN.
Sample Input
Sample Output
Source
USACO 2003 Fall Orange
题目分析:水题、悪くないやはりWA 2回、とても気がふさいで、主に题目の说明の中で1つの言叶に気づいていません:Each of the first nine digits can take a value between 0 and 9.Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number. 最後の数字がXかもしれない以外は0-9の数字しかないという意味です.コードは以下の通り:/*Coded By:MiYuLink:http://www.cnblogs.com/MiYu || http://www.cppblog.com/MiYuAuthor By : MiYuTest : 1Program : 2714*///#pragma warning( disable:4789 )#include#include #include #include #include
タイトルアドレス:
http://acm.hdu.edu.cn/showproblem.php?pid=2714
タイトルの説明:
ISBNTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 566 Accepted Submission(s): 172
Problem Description
Farmer John's cows enjoy reading books, and FJ has discovered that his cows produce more milk when they read books of a somewhat intellectual nature. He decides to update the barn library to replace all of the cheap romance novels with textbooks on algorithms and mathematics. Unfortunately, a shipment of these new books has fallen in the mud and their ISBN numbers are now hard to read.
An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first nine digits represent the book and the last digit is used to make sure the ISBN is correct. To verify that an ISBN number is correct, you calculate a sum that is 10 times the first digit plus 9 times the second digit plus 8 times the third digit ... all the way until you add 1 times the last digit. If the final number leaves no remainder when divided by 11, the code is a valid ISBN.
For example 0201103311 is a valid ISBN, since
10*0 + 9*2 + 8*0 + 7*1 + 6*1 + 5*0 + 4*3 + 3*3 + 2*1 + 1*1 = 55.
Each of the first nine digits can take a value between 0 and 9. Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number.
Your task is to fill in the missing digit from a given ISBN number where the missing digit is represented as '?'.
Input
* Line 1: A single line with a ten digit ISBN number that contains '?' in a single position
Output
* Line 1: The missing digit (0..9 or X). Output -1 if there is no acceptable digit for the position marked '?' that gives a valid ISBN.
Sample Input
15688?111X
Sample Output
1
Source
USACO 2003 Fall Orange
题目分析:水题、悪くないやはりWA 2回、とても気がふさいで、主に题目の说明の中で1つの言叶に気づいていません:Each of the first nine digits can take a value between 0 and 9.Sometimes it is necessary to make the last digit equal to ten; this is done by writing the last digit as X. For example, 156881111X is a valid ISBN number. 最後の数字がXかもしれない以外は0-9の数字しかないという意味です.コードは以下の通り:/*Coded By:MiYuLink:http://www.cnblogs.com/MiYu || http://www.cppblog.com/MiYuAuthor By : MiYuTest : 1Program : 2714*///#pragma warning( disable:4789 )#include