ID Key
Time limit1sMemory limit128 MB
Add the digit sum of each 13-digit ID to ten times its last three digits, then keep four digits as the key.
- Level
Easy1 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Problem
An ID card carries a 13 digit number. From those 13 digits you compute the ID Key, a four digit number, with these steps.
- Add up all 13 digits.
- Take the number formed by the last three digits and multiply it by 10.
- Add the value from step 1 and the value from step 2. If the sum has more than four digits, keep only its last four digits. If the sum is smaller than 1,000, add 1,000 to it. The four digit number left at the end is the ID Key.
Input
The first line has the number of people (). Each of the next lines has one person's 13 digit ID number. A number may start with 0.
Output
Print each person's ID Key on its own line, in the order the people are given. Always print four digits and keep any leading zero.