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

17817번 - Trol 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB2631168547.222%

문제

Stjepan recently received his bachelor’s degree in mathematics from the University of Zagreb. Naturally, his parents are very proud and have decided to give him all positive integers not greater than 260 as a gift. To keep them safe, he quickly stored all of those numbers in an array A, such that Ai = i.

His jealous friend Marin decided to prank him by repeatedly replacing each element of A with the sum of its digits until all elements of A consisted of a single digit. For example, the initial value of 197th element of A was 197. Marin first changed that value to 1 + 9 + 7 = 17 and then changed its value again to 1 + 7 = 8.

Stjepan is devastated and begs Marin to return his array to its initial state. Unfortunately, Marin won’t do that until Stjepan correctly answers his Q queries: “What is the sum of numbers from l-th to r-th element of A?”.

Help Stjepan answer those queries!

입력

The first line contains an integer Q (1 ≤ Q ≤ 100) from the task description.

The next Q lines contain two integers li and ri (1 ≤ li ≤ ri ≤ 260), the parameters of Marin’s i-th query.

출력

Output the answers to each of Marin’s Q queries. Each answer should be printed in a separate line and their order should match the order of the queries as they are given in the input.

제한

예제 입력 1

1
1 5

예제 출력 1

15

예제 입력 2

2
9 13
44 45

예제 출력 2

19
17
  • 1st query → A9 = 9, A10 = 1 + 0 = 1, A11 = 1 + 1 = 2, A12 = 1 + 2 = 3, A13 = 1 + 3 = 4. A9 + A10 + A11 + A12 + A13 = 9 +たす 1 +たす 2 +たす 3 +たす 4 = 19.
  • 2nd query → A44 = 4 + 4 = 8, A45 = 4 + 5 = 9. A44 + A45 = 8 + 9 = 17.

예제 입력 3

1
1998 2018

예제 출력 3

102

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2019/2020 > Contest #1 1번

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

출처

대학교 대회

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

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