#P6209. 「SWTR-4」Calculating Machine
「SWTR-4」Calculating Machine
Description
The way Little E computes the sum of several numbers is:
-
If there are more than numbers in the operation, compute from left to right in order.
-
If the two numbers have different lengths, the shorter one is automatically padded with leading zeros until the two numbers have the same length.
-
Starting from the least significant digit of the two numbers, compute the sum of the two digits at the current position plus the carry from the previous position, and write down the remainder of this sum divided by .
-
Carry rule: if the sum of the two digits at the current position plus the carry from the previous position is less than , do not carry; if the sum is greater than or equal to and less than or equal to , carry ; otherwise, carry .
For example: , , , , .
Because Little E’s calculating machine was killed by 360 Security as a virus, he wants you to help compute .
Input Format
The first line contains an integer — the number of numbers involved in the operation.
The second line contains integers — all numbers involved in the operation from left to right. You can also understand this as is to the left of .
Output Format
Output one integer in one line — the value of .
1
1
1
2
233 23333
23566
3
345 379 573
2317
4
1234 567 89 10
4000
5
19111010 19260817 19371213 19491001 20200110
239635161
Hint
[Sample Explanation]
.
[Sample Explanation]
.
[Constraints and Notes]
For of the testdata, .
For of the testdata, .
For of the testdata, , .
For of the testdata, , .
[Source]
idea: ET2006, std: Alex_Wei, problem checking: Isaunoya & FrenkiedeJong21 & chenxia25
Translated by ChatGPT 5
京公网安备 11011102002149号