No.933 Officer, It's This Guy
Problem Statement
Iot-kun found a girl made up of $N$ non-negative integers in a park.
Since the chance has come up, let's tell Iot-kun the age of the girl he found.
The age of the girl is defined as follows.
Among the numbers that make up the girl, let the $i$-th one be $P_i$.
Let $P_1×P_2×...×P_N=K$. Then, the value of $K$ after the following operation is the girl's age.
Operation: $K$=the sum of the digits of $K$ (repeated as long as the number of digits of $K$ $\neq 1$)
Input
$N$ $P_1$ $P_2$ $...$ $P_N$
$0 < N\le 10^5$
$0\le P_i\le 10^{18}$
Output
Output the girl's age, followed by a newline.
Sample
Sample 1
Input
5 1 1 2 5 14
Output
5
$K=1×1×2×5×14=140$, and the sum of its digits is $5$.
Since $K$ now has 1 digit, the girl is $5$ years old.
Sample 2
Input
1 95685
Output
6
$K=95685$, and the sum of its digits is $33$, so after the first operation $K=33$.
The second operation gives $K=3+3=6$, which has 1 digit, so the girl is $6$ years old. That's illegal, isn't it.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
leafirby
null