UberOA #12
Sensor Readings Digit-Sum Mode
估计简单可在线判题
Repeatedly replace each integer with the sum of its digits until every number is a single digit. Return the digit that appears most often; if counts are tied, take the larger digit.
This site's standard input/output is stated explicitly.
输入格式
The first line contains n, and the second line contains n non-negative integers; 1≤n≤100, 0≤a[i]≤1000000.
输出格式
Output one integer answer.
样例 1
输入:
4
123 456 789 101
输出:
6
样例 2
输入:
2
1 2
输出:
2
样例 3
输入:
3
0 9 18
输出:
9
样例说明
Example 1: the digital roots are 6, 6, 6, 2, so return 6. Example 2: 1 and 2 appear once each; on the tie, take 2. Example 3: the digital roots are 0, 9, 9, so return 9; a positive multiple of 9 does not have digital root 0.