22828_ISBN

2022-5-16 18:23| 发布者: Hocassian| 查看: 29| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506996727300-Problem List-采集的数据-后羿采集器.html

Pro.ID

22828

Title

ISBN

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22828

AC

50

Submit

262

Ratio

19.08%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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 '?'.

    输入

    多测试用例,每个一行。

    Line 1: A single line with a ten digit ISBN number that contains '?' in a single position

    输出

    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

    样例输入

    15688?111X

    样例输出

    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部