#CCBCHBAHAI0000048. UPC check digit (UPC Check Digit)
UPC check digit (UPC Check Digit)
UPC check digit (UPC Check Digit)
Source: Problem Solving and Program Design in C
Version: Phuoc Hung OJ Extended
Problem
Given 12 decimal digits
where is the UPC check digit.
Compute
$$S=3(d_1+d_3+d_5+d_7+d_9+d_{11}) +(d_2+d_4+d_6+d_8+d_{10}).$$The required check digit is
The code is valid if and only if
Print the computed check digit and whether the given 12 digits are valid.
Input
One line contains exactly 12 integers , each a digit from to .
Output
Print on the first line. Print VALID on the second line if ; otherwise print INVALID.
Subtask
Subtask 1 (100 points): for every .
Example
Input
0 3 6 0 0 0 2 9 1 4 5 2
Output
2
VALID
Explanation
Here , so . The last digit is also , therefore the code is valid.