-->
当前位置:首页 > 题库

PROGRAMMING:Enigmatic Chinese remainder theorem

Luz5年前 (2021-05-10)题库500
It is known that x satisfies: X mod a [0] = B [0], X mod a [1] = B [1], X mod a [2] = B [2],..., X mod a [i] = B [i],... (0 < a [I] < = 10). Find how many X's in a positive integer less than or equal to n.
###Input format:
The first line of input data is a positive integer T, which indicates that there are t groups of test data. The first line of each group of test data is two positive integers n, m (0 < n < = 1000000000, 0 < m < = 10), indicating that x is less than or equal to N, and there are m elements in array A and B respectively. The next two lines, each with m positive integers, are elements of a and B.
###Output format:
Corresponding to each group of inputs, a positive integer is output in an independent line, which indicates the number of X satisfying the condition.
###Input example:
Here is a set of inputs. For example:
```in
three
10 3
1 2 3
0 1 2
100 7
3 4 5 6 7 8 9
1 2 3 4 5 6 7
10000 10
1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9
```
###Output example:
The corresponding output is given here. For example:
```out
one
0
three
```







answer:If there is no answer, please comment