luogu#P4999. 烦人的数学作业
烦人的数学作业
Background
The NOIP2018 preliminary round is over, but H still has to go to school. Going to school means finishing the homework assigned by teachers, and H is really worried. Among the pile of homework, the math homework assigned by Mr. G is the most annoying, and H can never finish it.
Problem Description
Recently, Mr. G has been reading some books about number problems. Every day, he worries that the students are too “smart”, and they can do all homework “perfectly” (by getting the answers). Mr. G is “kept in the dark” (but actually knows it well). To help students improve, Mr. G always creates some “easy” (but actually nasty) problems as homework. Below is the statement of the last problem in the math homework:
Given an interval , find the sum of digits of every number in the range from to . For example, the sum of digits of is .
(.)
The students all solved it. Mr. G thought this last problem was basically useless, so he quickly modified it: he made the range extremely large, and there are test cases. Output the final answer .
(.) (.)
The students were all stuck. But H is preparing for NOIP2018 and has no time to finish Mr. G’s math homework (actually, Ta just does not want to do it), so Ta came to you, hoping you can help Ta and the classmates finish this annoying math homework.
Input Format
There are lines in total.
Line contains , meaning there are test cases.
Lines to contain and .
Output Format
Output lines.
For each line, output the sum of digits over the interval from to , taken .
2
24 69
70 120
411
498
Hint
For of the testdata, .
For of the testdata, , and .
Translated by ChatGPT 5