#P10404. 「XSOI-R1」原神数
「XSOI-R1」原神数
Problem Description
A Genshin number must satisfy both of the following conditions:
- is a prime number.
- All decimal digits of are pairwise distinct.
For example, is not a Genshin number because its hundreds digit equals its ones digit; is not because it is not prime; is a Genshin number.
There are queries. You need to find the number of Genshin numbers between and (inclusive).
Input Format
The first line contains a positive integer .
The next lines each contain two positive integers and .
Output Format
Output lines. Each line contains one positive integer, which is the answer to the corresponding query.
4
45 66
100 140
2 90
114514 1919810
4
6
23
13321
Hint
Sample Explanation #1
Between and , the Genshin numbers are , a total of .
Constraints and Notes
This problem uses bundled tests.
- Subtask 0 (15 pts): .
- Subtask 1 (15 pts): .
- Subtask 2 (35 pts): .
- Subtask 3 (35 pts): .
For all testdata, it is guaranteed that and .
Translated by ChatGPT 5