F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Rikka with Number

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 770    Accepted Submission(s): 230


Problem Description
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=(A_1A_2...A_m)_d(A_i \in [0,d),A_1 \neq 0)$ is good if and only $A_1-A_m$ 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 \geq 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?  
 

Input
The first line contains a number $t(1 \leq t \leq 20)$, the number of the testcases.

For each testcase, the first line contains two decimal numbers $L,R(1 \leq L \leq R \leq 10^{5000})$.
 

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

Sample Input
2 5 20 123456 123456789
 

Sample Output
3 114480
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 10:31:02, Gzip enabled