#P7199. [COCI 2019/2020 #1] Trol
[COCI 2019/2020 #1] Trol
Description
Stjepan has recently obtained a bachelor’s degree in mathematics at the University of Zagreb. Naturally, his parents are proud of him and decided to give him all positive integers not exceeding as a gift. To keep them safe, he quickly stored all the numbers into a sequence , where .
A friend of his, Marin, who is jealous of him, decided to play a prank: repeatedly replace every element in with the sum of its digits, until it eventually becomes a single-digit number.
For example, the initial value of the -th element is . Marin first changed it to , and then changed it once more to .
Stjepan was extremely shocked and asked Marin to restore the sequence to its initial state. Unfortunately, Marin will not do so until Stjepan correctly answers queries. For each query, Stjepan needs to answer the sum of the elements from the -th to the -th term in the sequence .
Help Stjepan answer these queries.
Input Format
The first line contains an integer , the number of queries.
The next lines each contain two positive integers , representing the interval range of Marin’s -th query.
Output Format
Output the answers to the queries. Separate answers with newline characters, and output them in the order of the queries.
1
1 5
15
2
9 13
44 45
19
17
1
1998 2018
102
Hint
Constraints
For of the testdata, all queries satisfy .
For of the testdata, all queries satisfy .
For of the testdata, , and all queries satisfy .
Notes
The scoring of this problem follows the original COCI problem settings, with a full score of .
This problem is translated from COCI2019-2020 CONTEST #1 T1 Trol .
Translated by ChatGPT 5
京公网安备 11011102002149号