#P7433. [THUPC 2017] 老司机

    ID: 8301 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2017快速傅里叶变换 FFT快速数论变换 NTTTHUPC

[THUPC 2017] 老司机

Problem Description

There are few pedestrians on the 4th Ring Road, and car gods often compete there.

The road is still here today, but the experienced drivers of those years are nowhere to be seen.

When Mr. B is in a bad mood, he likes to speed on the 4th Ring Road. Watching the scenery flying past the window, Mr. B thinks of Mr. R and Mr. G from the past; of YJQ and FLZ of the present; of the vastness of the universe and the infinity of space-time; and also of this problem.

Given n,X,Y,Zn, X, Y, Z, it is guaranteed that XX is an integer power of 22, YY is an integer power of 33, and ZZ is an integer power of 55, and that 1n10001 \le n \le 1000, 1X×Y×Z20001 \le X \times Y \times Z \le 2000.

You are given four arrays of length nn: {ai},{bi},{ci},{ri}\{a_i\}, \{b_i\}, \{c_i\}, \{r_i\} (0ai,bi,ci,ri1090 \le a_i, b_i, c_i, r_i \le 10^9).

For each (u,v,w)(u, v, w), count how many solutions {xi},{yi},{zi}\{x_i\}, \{y_i\}, \{z_i\} there are.

They must satisfy that for all ii, $a_i \le x_i, b_i \le y_i, c_i \le z_i, r_i \ge x_i - a_i + y_i - b_i + z_i - c_i$.

And

(i=1nxi)modX=u(\sum_{i=1}^n x_i) \bmod X = u (i=1nyi)modY=v(\sum_{i=1}^n y_i) \bmod Y = v (i=1nzi)modZ=w(\sum_{i=1}^n z_i) \bmod Z = w

Let the number of solutions be F(u,v,w)F(u, v, w).

Output

$$\operatorname*{xor}_{0\le u< X,0\le v<Y,0\le w<Z}((uYZ+vZ+w)\times(F(u,v,w)\bmod466560001))$$

Input Format

The first line contains n,X,Y,Zn, X, Y, Z.

The next nn lines each contain four integers ai,bi,ci,ria_i, b_i, c_i, r_i.

Output Format

Output one integer in one line as the answer.

3 2 3 1
0 0 0 1
0 0 0 2
0 0 0 3
573
3 2 3 5
0 0 0 1
0 0 0 2
0 0 0 3
253

Hint

From THUPC (THU Programming Contest, Tsinghua University Programming Contest) 2017.

Translated by ChatGPT 5