P1055 [NOIP 2008 Junior] ISBN Number
Description
Every formally published book has an ISBN number associated with it. An ISBN consists of $9$ digits, $1$ check digit, and $3$ 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, $0$ represents English); the three digits after the first separator `-` indicate the publisher (for example, $670$ 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 $1$, add the second digit multiplied by $2$, and so on. Take the resulting sum $\bmod 11$; the remainder is the check digit. If the remainder is $10$, then the check digit is the uppercase letter $X$. For example, in the ISBN `0-670-82162-4`, the check digit $4$ is obtained as follows: take the nine digits `067082162` from left to right, multiply them by $1,2,\dots,9$ respectively and sum, i.e., $0\times 1 + 6\times 2 + \cdots + 2\times 9 = 158$, then take $158 \bmod 11$, whose result $4$ 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 `-`).
Explanation/Hint
2008 Junior Problem 1.
Translated by ChatGPT 5