P29112 [洛谷] 「SWTR-4」Calculating Machine
普及
题目描述

Problem Background

Little E is using his Calculating Machine to compute the sum of $n$ decimal numbers $a_1, a_2, \cdots, a_n$.

Problem Description

Little E's method of calculating the sum of several numbers is as follows:

  • If there are more than 2 numbers involved in the operation, the calculation is performed from left to right.
  • If the numbers have different digit lengths, the number with fewer digits is automatically padded with leading zeros until both numbers have the same length.
  • Starting from the least significant digit of both numbers, compute the sum of the current digits plus the carry from the previous digit, and write down the remainder of this sum divided by 10.
  • Carry rules: If the sum of the current digits plus the carry from the previous digit is less than 7, there is no carry; if the sum is between 7 and 13 inclusive, carry one digit; otherwise, carry two digits.

For example: $2 + 4 = 6$, $7 + 8 = 25$, $61 + 6 = 177$, $38 + 169 = 217$, $3 + 900 = 1903$.

Since Little E's calculating machine was mistakenly killed by the 360 security virus as a virus, he wants you to help him find the sum $a_1 + a_2 + \cdots + a_n$.

Input Format

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

The second line contains $n$ integers, $a_1, a_2, \cdots, a_n$ — the numbers involved in the operation from left to right, which can also be understood as $a_i$ being to the left of $a_{i+1}$.

Output Format

A single line containing an integer — the sum of $a_1 + a_2 + \cdots + a_n$.

Sample Input and Output

Input Sample #1

1
1

Output Sample #1

1

Input Sample #2

2
233 23333

Output Sample #2

23566

Input Sample #3

3
345 379 573

Output Sample #3

2317

Input Sample #4

4
1234 567 89 10

Output Sample #4

4000

Input Sample #5

5
19111010 19260817 19371213 19491001 20200110

Output Sample #5

239635161

Notes

Sample 3 Explanation

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

Sample 4 Explanation

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

Data Range and Constraints

For 10% of the data, $n = 1$.

For 30% of the data, $n \leq 2$.

For 60% of the data, $n \leq 10$, $a_i \leq 10^5$.

For 100% of the data, $1 \leq n \leq 2020$, $0 \leq a_i \leq 10^9$.

Source

Sweet Round 04 A

Idea: ET2006, std: Alex_Wei, tester: Isaunoya & FrenkiedeJong21 & chenxia25

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 1
样例输出
1