#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 22 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 1010.

  • Carry rule: if the sum of the two digits at the current position plus the carry from the previous position is less than 77, do not carry; if the sum is greater than or equal to 77 and less than or equal to 1313, carry 11; otherwise, carry 22.

For example: 2+4=62+4=6, 7+8=257+8=25, 61+6=17761+6=177, 38+169=21738+169=217, 3+900=19033+900=1903.

Because Little E’s calculating machine was killed by 360 Security as a virus, he wants you to help compute a1+a2++ana_1+a_2+\dots+a_n.

Input Format

The first line contains an integer nn — the number of numbers involved in the operation.

The second line contains nn integers a1,a2,,ana_1,a_2,\cdots,a_n — all numbers involved in the operation from left to right. You can also understand this as aia_i is to the left of ai+1a_{i+1}.

Output Format

Output one integer in one line — the value of a1+a2++ana_1+a_2+\cdots+a_n.

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 33 Explanation]

345+379+573=1734+573=2317345+379+573=1734+573=2317.

[Sample 44 Explanation]

1234+567+89+10=2801+89+10=3990+10=40001234+567+89+10=2801+89+10=3990+10=4000.

[Constraints and Notes]

For 10%10\% of the testdata, n=1n=1.

For 30%30\% of the testdata, n2n \leq 2.

For 60%60\% of the testdata, n10n \leq 10, ai105a_i \leq 10^5.

For 100%100\% of the testdata, 1n20201 \leq n \leq 2020, 0ai1090 \leq a_i \leq 10^9.

[Source]

Sweet Round 04  \ \ A

idea: ET2006, std: Alex_Wei, problem checking: Isaunoya & FrenkiedeJong21 & chenxia25

Translated by ChatGPT 5