|
||||||||||
The More The BetterTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3747 Accepted Submission(s): 987 Problem Description Given an sequence of numbers {X1, X2, ... , Xn}, where Xk = (A * k + B) % mod. Your task is to find the maximum sub sequence {Y1, Y2, ... , Ym} where every pair of (Yi, Yj) satisfies Yi + Yj <= L (1 ¡Ü i < j ¡Ü m), and every Yi <= L (1 ¡Ü i ¡Ü m ). Now given n, L, A, B and mod, your task is to figure out the maximum m described above. Input Multiple test cases, process to the end of input. Every test case has a single line. A line of 5 integers: n, L, A, B and mod. (1 ¡Ü n ¡Ü 2*107, 1 ¡Ü L ¡Ü 2*109, 1 ¡Ü A, B, mod ¡Ü 109) Output For each case, output m in one line. Sample Input
Sample Output
Source | ||||||||||
|