AmazonOA #10
Pascal Triangle Encryption
Estimated HardJudge-ready
Topics (AI-labelled)Bits & Math
In each round, take the sum of every two adjacent digits modulo 10 to get a new array whose length is 1 less. Repeat until 2 digits remain, then output the string formed by those two digits, keeping leading zeros.
Input
The first line contains n (2..100000); the second line contains n digits (0..9).
Output
Output one integer, the answer required by the problem.
Example 1
Input:
4
4 5 6 7
Output:
04
Example 2
Input:
2
0 0
Output:
00
Example 3
Input:
3
9 1 9
Output:
00
Example notes
Example 1: [4,5,6,7] first becomes [9,1,3], then [0,4], so the output is 04; the leading zero must not be dropped. Example 2: two digits already remain, so output 00 directly. Example 3: the adjacent sums 9+1 and 1+9 are both 0 modulo 10, so output 00.
Editorial
Loading solution…