#K69202. ISBN-10 Validator
ISBN-10 Validator
ISBN-10 Validator
In this problem, you are required to determine whether a given string is a valid ISBN-10 identifier. An ISBN-10 consists of 10 characters. The first 9 characters must be digits ('0'-'9'), and the last character can be a digit or the letter 'X' (which represents the value 10). The validity of an ISBN-10 is determined by the following formula:
$$\sum_{i=1}^{10} i \cdot d_i \equiv 0 \pmod{11}$$
Here, each di represents the numeric value of the i-th character (with 'X' being interpreted as 10). If the sum is divisible by 11, then the ISBN-10 is valid; otherwise, it is invalid.
Your task is to read an input string from standard input, validate it as an ISBN-10, and print VALID
if it meets the criteria or INVALID
otherwise.
inputFormat
The input consists of a single line containing a string that represents a candidate ISBN-10 identifier. The string may contain digits and the letter 'X'.
outputFormat
Output a single line containing either VALID
if the ISBN-10 is valid according to the criteria provided, or INVALID
if it is not.
0471958697
VALID