Logo
(追記) (追記ここまで)

13245번 - Sum of digits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB129907782.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]

제한

예제 입력 1

15

예제 출력 1

66

예제 입력 2

9935125239801570

예제 출력 2

714619374344308434

예제 입력 3

1000

예제 출력 3

13501

예제 입력 4

83

예제 출력 4

678

힌트

출처

Olympiad > All-Ireland Programming Olympiad > 2016 AIPO National Finals 6번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /