#P1055. [NOIP 2008 普及组] ISBN 号码
[NOIP 2008 普及组] ISBN 号码
Description
Every formally published book has an ISBN number associated with it. An ISBN consists of digits, check digit, and separators. Its prescribed format is x-xxx-xxxxx-x, where the symbol - is the separator (the minus sign on the keyboard), and the last character is the check digit. For example, 0-670-82162-4 is a standard ISBN. The first digit indicates the publication language of the book (for example, represents English); the three digits after the first separator - indicate the publisher (for example, represents Viking Press); the five digits after the second separator indicate the book’s identifier at that publisher; the last character is the check digit.
The check digit is computed as follows:
Multiply the first digit by , add the second digit multiplied by , and so on. Take the resulting sum ; the remainder is the check digit. If the remainder is , then the check digit is the uppercase letter . For example, in the ISBN 0-670-82162-4, the check digit is obtained as follows: take the nine digits 067082162 from left to right, multiply them by respectively and sum, i.e., , then take , whose result is the check digit.
Your task is to write a program to determine whether the check digit in the input ISBN number is correct. If it is correct, output Right only; if it is incorrect, output the ISBN number you believe to be correct.
Input Format
A character sequence representing a book’s ISBN number (the input is guaranteed to conform to the format requirements of ISBN numbers).
Output Format
One line. If the check digit of the input ISBN number is correct, output Right; otherwise, output the correct ISBN number in the prescribed format (including the separator -).
0-670-82162-4
Right
0-670-82162-0
0-670-82162-4
Hint
2008 Junior Problem 1.
Translated by ChatGPT 5
京公网安备 11011102002149号