P6052 [RC-02] yltx Prime Pair

Background

yltx has once again come up with a problem that they cannot solve...

Description

yltx defines that if a **prime** pair $(x,y)$ satisfies that $x\times y-3\times (x-y)$ is prime, then it is called a yltx pair. He gives you $T$ pairs $(x,y)$. Please check whether they are yltx pairs. The data is given in the form of a seed $(x_0,y_0)$. Perform $T$ times of $x_0\leftarrow (7x_0+13)\ \mathrm{xor}\ (x_0\div 13-7)$. For the value obtained in the $i$-th execution, first take modulo $10^4$, add $10^4$, take modulo $10^4$ again, then add $1$, and you get the $x$ of the $i$-th test case. Here division means integer division, and $x_0$ is treated as a 32-bit signed integer. Use the same method to get $y$. Data generation template: ```cpp #include using namespace std; int T,x_0,y_0; int main() { scanf("%d%d%d",&T,&x_0,&y_0); while(T--){ x_0=((7*x_0+13)^(x_0/13-7)); y_0=((7*y_0+13)^(y_0/13-7)); int x=(x_0%10000+10000)%10000+1,y=(y_0%10000+10000)%10000+1; //x,y即为一组(x,y)。 } return 0; } ```

Input Format

The first line contains three integers $T,x_0,y_0$.

Output Format

$1$ line. Output how many pairs are yltx pairs.

Explanation/Hint

The Constraints for each test point are as follows: | Test Point | T | Subtask | | :---: | :---: | :---: | | 1 | $\le10$ | 1 | | 2 | $\le20$ | 1 | | 3 | $\le50$ | 1 | | 4 | $\le100$ | 1 | | 5 | $\le500$ | 1 | | 6 | $\le1000$ | 1 | | 7 | $\le5000$ | 2 | | 8 | $\le10^4$ | 2 | | 9 | $\le5\times10^4$ | 2 | | 10 | $\le4\times10^5$ | 2 | | 11 | $\le10^6$ | 2 | | 12 | $\le5\times10^6$ | 2 | | 13 | $\le4\times10^7$ | 3 | | 14 | $\le4\times10^7$ | 3 | | 15 | $\le4\times10^7$ | 3 | | 16 | $\le4\times10^7$ | 3 | | 17 | $\le4\times10^7$ | 3 | | 18 | $\le4\times10^7$ | 3 | | 19 | $\le4\times10^7$ | 3 | | 20 | $\le4\times10^7$ | 3 | Each Subtask is tested as a bundled group of test points. This problem provides testdata for download, but we hope you will use the data to do the right thing. Translated by ChatGPT 5