#P4411. [BJWC2010] 取数游戏
[BJWC2010] 取数游戏
Description
Xiao C has just learned the Euclidean algorithm and is enjoying it, but Xiao P comes to make trouble and leaves Xiao C with a hard problem. You are given numbers, denoted by . Now Xiao P asks Xiao C to pick numbers one by one in order. The first number can be chosen arbitrarily. Suppose the current number is . To pick the next number with , the number must satisfy .
How many numbers should be picked? Naturally, as many as possible. Needless to say, this is not only a challenge for Xiao C, but also for you.
Input Format
The first line contains two numbers and .
The second line contains numbers separated by spaces: .
Output Format
Output a single line with one number, the maximum count of numbers that can be picked according to the rule.
5 6
7 16 9 24 6
3
Hint
Sample Explanation
Pick numbers: . , .
Constraints
For 30% of the testdata, .
For 100% of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号