| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 512 MB | 129 | 90 | 77 | 82.796% |
It is easy to compute the sum of the numbers in the sequence from 0 to n with the formula n*(n+1)/2. That is: 0 + 1 + 2 + .... + n = n*(n+1)/2
This problem is a bit harder: what about the sum of the digits in the sequence [0, 1, ..., n]?
Write a program that computes the sum of the digits that can be found when counting from 0 to n.
For n = 15 we want to sum the digits that appear in the sequence [0, 1, 2, ..., 14, 15].
The result is: 1 +たす 2 +たす 3 +たす 4 +たす 5 +たす 6 +たす 7 +たす 8 +たす 9 +たす 1 +たす 0 +たす1 +たす 1 +たす 1 +たす 2 +たす 1 +たす 3 +たす 1 +たす 4 +たす 1 +たす 5 =わ 66
A single line with an integer n (1 ≤ n ≤ 1016)
A single line with the sum of digits in the sequence [0, 1, ..., n-1, n]
15
66
9935125239801570
714619374344308434
1000
13501
83
678