European countries use a 12-digit code called European Article Number (EAN) for each product. Each EAN ends with a check digit, which is calculated by the following rules:
Add the second, fourth, sixth, eighth, tenth, and twelfth digits (as $a$).
Add the first, third, fifth, seventh, ninth, and eleventh digits (as $b$).
Multiply $a$ by $3$ and add it to $b$ (as $x$).
Subtract $1$ from $x$ ( as $y$).
Compute the remainder when $y$ is divided by $10$ (as $z$).
Substract $z$ from $9$.
Write a program that reads the first 12 digits of an EAN, and then displays the calculated check digit.
12 digits
1 digit
No. | Testdata Range | Score |
---|---|---|
1 | 0~3 | 100 |
No. | Time Limit (ms) | Memory Limit (KiB) | Output Limit (KiB) | Subtasks |
---|---|---|---|---|
0 | 1000 | 65536 | 65536 | |
1 | 1000 | 65536 | 65536 | |
2 | 1000 | 65536 | 65536 | |
3 | 1000 | 65536 | 65536 |