Score: 625 points
问题描述
请注意特殊的输入格式。
在 xy 平面上有 N 个点 (Xi,Yi),这些点在输入中给出。
同时,给出了 Q 对整数 (Aj,Bj)。
定义 f(Aj,Bj) 为满足 Yi≥Aj×Xi+Bj 的索引 i 的数量。
求 j=1∑Qf(Aj,Bj)。
此处,Q 可能非常大,因此不直接给出 (Aj,Bj)。
而是给出 G0、Ra 和 Rb,并通过以下方式生成 (Aj,Bj):
- 首先,对于 n≥0,定义 Gn+1=(48271×Gn)mod(231−1)。
- 对于 j=1,2,…,Q,按以下方式生成 (Aj,Bj):
- Aj=−Ra+(G3j−2mod(2×Ra+1))
- $B_j = -R_b + ((G_{3j - 1} \times (2^{31}-1) + G_{3 j}) \mod (2 \times R_b + 1) )$
通过这种方法可以证明,Aj 和 Bj 满足以下约束条件:
- −Ra≤Aj≤Ra
- −Rb≤Bj≤Rb
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Pay attention to the special input format.
There are N points (Xi,Yi) in the xy-plane. You are given these points in the input.
Also, Q pairs of integers (Aj,Bj) are given.
Define f(Aj,Bj) as the number of indices i satisfying Yi≥Aj×Xi+Bj.
Find j=1∑Qf(Aj,Bj).
Here, Q gets very large, so (Aj,Bj) are not given directly.
Instead, G0, Ra, and Rb are given, and (Aj,Bj) are generated as follows:
- First, for n≥0, define Gn+1=(48271×Gn)mod(231−1).
- For j=1,2,…,Q, generate (Aj,Bj) as follows:
- Aj=−Ra+(G3j−2mod(2×Ra+1))
- $B_j = -R_b + ((G_{3j - 1} \times (2^{31}-1) + G_{3 j}) \mod (2 \times R_b + 1) )$
From this method, it can be shown that Aj and Bj satisfy the following constraints:
- −Ra≤Aj≤Ra
- −Rb≤Bj≤Rb
Constraints
- All input values are integers.
- 1≤N≤5000
- 1≤Q≤107
- ∣Xi∣,∣Yi∣≤108
- The pairs (Xi,Yi) are distinct.
- 0≤G0<(231−1)
- 0≤Ra≤108
- 0≤Rb≤1016
The input is given from Standard Input in the following format:
N
X1 Y1
X2 Y2
⋮
XN YN
Q
G0 Ra Rb
Output
Print the answer as an integer.
7
2 -2
-1 -2
0 1
2 1
-2 2
1 2
0 -1
10
1 5 5
Sample Output 1
36
This input contains ten questions.
The generated (Aj,Bj) are $(-2,4),(0,2),(-4,-2),(4,-5),(3,1),(-1,3),(2,-5),(3,-1),(3,5),(3,-2)$.