Verification Digit
Time limit1sMemory limit128 MB
Compute the check digit as the sum of squares of five given digits, mod 10.
- Level
Easy1 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
KOI Electronics assigns a six-digit serial number to each computer. The first five positions are five digits representing a number from 00000 to 99999, and the sixth position is the verification digit.
The verification digit is found by squaring each of the first five digits, adding those squares, and taking the remainder after division by 10.
For example, if the first five digits are 0, 4, 2, 5, and 6, the sum of squares is 0 + 16 + 4 + 25 + 36 = 81. Since 81 leaves a remainder of 1 when divided by 10, the verification digit is 1.
Input
The first line contains the first five digits of the serial number, separated by spaces.
Output
Print the verification digit on the first line.