2049. Digital Root

单点时限: 2.0 sec

内存限制: 256 MB

Let f(n) be a sum of digits for positive integer n. If f(n) is one-digit number then it is a digital root for n and otherwise digital root of n is equal to digital root of f(n). For example, digital root of 987 is 6. Your task is to find digital root for expression A1A2AN + A1A2AN-1 + … + A1*A2 + A1.

输入格式

Input file consists of few test cases. There is K (1<=K<=5) in the first line of input. Each test case is a line. Positive integer number N is written on the first place of test case (N<=1000). After it there are N positive integer numbers (sequence A). Each of this numbers is non-negative and not more than 10^9.

输出格式

Write one line for every test case. On each line write digital root for given expression.

样例

Input
1
3 2 3 4
Output
5

29 人解决,56 人已尝试。

31 份提交通过,共有 122 份提交。

5.6 EMB 奖励。

创建: 16 年,5 月前.

修改: 6 年,8 月前.

最后提交: 9 月,3 周前.

来源: N/A

题目标签