luogu#P4942. 小凯的数字
小凯的数字
Background
NOIP 2018 original mock contest problem T1.
Difficulty: similar to NOIP Day 1 T1 or Day 2 T1.
Did you notice that it is somewhat similar in spirit to NOIP 2017 Day 1 T1.
Problem Description
One day, Xiao Kai had a sudden idea and wrote down a sequence of numbers: .
For example, when , the number is .
When , the number is .
Xiao Kai really likes the digit , so he wants to ask you: what is the remainder when the number he wrote is divided by ?
For example, when , .
Input Format
The first line contains an integer , meaning Xiao Kai has queries.
Lines to each contain two integers , representing the range of numbers.
Output Format
For each query, output one line with one integer, which is the answer to Xiao Kai’s query.
2
2 5
8 12
5
5
3
1 999
123 456
13579 24680
0
6
0
Hint
Explanation of Sample 1: , and .
For of the testdata: , and .
For of the testdata: , and .
For of the testdata: , and .
For of the testdata: , , and .
Translated by ChatGPT 5