DWITE '06 R5 #3 - UPC Check Digit

View as PDF

Submit solution

Points: 5
Time limit: 0.6s
Memory limit: 16M

Problem type
DWITE Online Computer Programming Contest, February 2006, Problem 3

The final digit of a Universal Product Code is a check digit computed so that summing the even-numbered digits, plus 3 times the odd-numbered digits, modulo 10, is 0.

For example, take the UPC 070617006092. The sum of the even numbered digits is 7+6+7+0+0+2 = 22, and the sum of the odd-numbered digits is 0+0+1+0+6+9 = 16. The total sum is 22 + 3 \times 16 = 70 \equiv 0 \pmod {10}. So the code is valid.

The input will contain five lines of data. Each line will contain a 12 digit UPC that may have an invalid check digit.

The output will contain five lines of data. Each line will contain the UPC with the correct check digit.

Sample Input

070617006093
036000291455
123456789097
246809753116
543210987665

Sample Output

070617006092
036000291452
123456789098
246809753116
543210987667

Comments

There are no comments at the moment.