#P1055. ISBN Validator
ISBN Validator
ISBN Validator
Every officially published book has an ISBN number following the format \(x-xxx-xxxxx-x\), where each x
is a digit and the hyphen '-' is the separator. The first digit represents the publication language (for example, 0 for English); the three digits following the first hyphen indicate the publisher; the next five digits represent the book's number in that publisher; and the final character is the identification code.
The identification code is calculated as follows. Suppose the first 9 digits (after removing the separators) are \(d_1, d_2, \dots, d_9\). Compute the weighted sum:
\[
S = 1\times d_1 + 2\times d_2 + \cdots + 9\times d_9
\]
Then the identification code is \(S \bmod 11\). If \(S \bmod 11 = 10\), then the identification code is the capital letter X
instead of a digit.
Your task is to write a program that checks whether the identification code in the given ISBN is correct. If it is, output Right
. Otherwise, output the corrected ISBN number in the same format.
inputFormat
A single line containing the ISBN string in the format x-xxx-xxxxx-x
.
outputFormat
Output Right
if the provided ISBN's identification code is correct; otherwise, output the corrected ISBN in the format x-xxx-xxxxx-x
.
sample
0-670-82162-4
Right