Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Currently, evaluating the significance of license plates, phone numbers, birth dates, or any sequence of digits is of interest to many people. The way to assess the beauty of a sequence of numbers is as follows: Calculate the sum of the digits in the sequence. If the sum is a single-digit number, that is the beauty value (beauty score) of the sequence. Otherwise, continue calculating the sum of the digits until you get a single-digit number.
Example:
- For the birth date sequence
02022020
, the sum of the digits is8
, so the beauty score of the sequence is8
. - For the phone number
0912345678
, the sum of the digits is45
. Continuing to calculate the sum gives9
, so the beauty score of the sequence is9
.
Requirement:
- Given a sequence with ~ n~ digits, evaluate the beauty score of the given sequence.
Input
- Contains a sequence with ~ n ~ digits (~ n \leq 10^5 ~).
Output
- An integer representing the beauty score of the sequence.
Sample Input
02022020
Sample Output
8
Bình luận