Responsive image

问题 I: Rikka with Number

问题 I: Rikka with Number

时间限制: 8 Sec  内存限制: 128 MB
提交: 2  解决: 2
[提交][状态][讨论版][命题人:]

题目描述

As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:
In radix d, a number K=(A1A2...Am)d(Ai∈[0,d),A1≠0) is good if and only A1−Am is a permutation of numbers from 0 to d−1.
A number K is good if and only if there exists at least one d≥2 and K is good under radix d.
Now, Yuta wants to calculate the number of good numbers in interval [L,R]
It is too difficult for Rikka. Can you help her?  

输入描述

The first line contains a number t(1≤t≤20), the number of the testcases. 

For each testcase, the first line contains two decimal numbers L,R(1≤L≤R≤105000).

输出描述

For each testcase, print a single line with a single number -- the answer modulo 998244353.

样例输入

2
5 20
123456 123456789

样例输出

3
114480
[提交][状态]
ACM算法攻关部