#P5330. [SNOI2019] 数论
[SNOI2019] 数论
Description
Given positive integers , an integer set of size , and an integer set of size , please compute:
$$\sum_{i=0}^{T-1}[(i\bmod P) \in A \land (i\bmod Q) \in B]$$In other words, ask how many non-negative integers less than satisfy: the remainder of divided by belongs to , and the remainder of divided by belongs to .
Input Format
The first line contains integers separated by spaces: .
The second line contains integers separated by spaces, representing the set . It is guaranteed that all are pairwise distinct, and .
The third line contains integers separated by spaces, representing the set . It is guaranteed that all are pairwise distinct, and .
Output Format
Output one integer on a single line, denoting the answer.
4 6 3 3 14
0 1 3
2 4 5
4
Hint
For all testdata, , , and .
For of the testdata, .
For another of the testdata, .
For another of the testdata, is a common multiple of and .
For another of the testdata, and are coprime, and .
For another of the testdata, and are coprime.
For another of the testdata, .
For the remaining of the testdata, there are no special constraints.
- 2023.11.17 Added three groups of hack testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号