#P5676. [GZOI2017] 小z玩游戏
[GZOI2017] 小z玩游戏
Description
Little z is very bored.
Little z wants to play games.
Little z has new games. The apparent fun level of the -th game is .
Little z is picky. He will only play a game whose apparent fun level is an integer multiple of his excitement level.
Since some games are actually fun and some are not, after finishing the -th game, Little z’s excitement level will become .
It is known that Little z’s initial excitement level is . Please determine how many games Little z might play twice.
Input Format
The first line contains a positive integer , indicating the number of testdata groups, up to groups.
For each group of testdata:
- The first line contains a positive integer , indicating the number of games.
- The second line contains positive integers. The -th number indicates that the apparent fun level of the -th game is .
- The third line contains positive integers. The -th number indicates that after Little z finishes the -th game, his excitement level will become .
Output Format
Output lines in total.
Each line contains one positive integer, indicating for the corresponding testdata group, the number of games that Little z might play twice.
5
1
100000
100000
5
1 2 6 15 35
5 7 9 2 3
5
2 3 5 35 21
7 11 7 3 2
10
6 15 77 12 24 37 35 99 55 42
4 2 5 7 11 3 6 8 9 10
10
6540 5604 567 57065 60 670 6870 1230 465 6540
12 5 37 3 34 13 17 18 10 12
1
3
3
8
5
Hint
Explanation for Sample 2
Numbers represent game indices, and arrows indicate the next one.
- Case : .
- Case : .
- Case : .
So Little z might play games twice.
No matter what, Little z cannot play game or twice.
Constraints

Translated by ChatGPT 5
京公网安备 11011102002149号