luogu#P4932. 浏览器

浏览器

Background

When playing Slay the Spire on Edge, __stdcall often finds that the mouse stops working, which makes her very upset. Therefore, she decided to let you experience the pain caused by Edge as well.

Problem Description

__stdcall gives you nn points. The ii-th point has weight xix_i. For two points uu and vv, if the result of xuxorxvx_u \operatorname{xor}x_v has an odd number of 11's in its binary representation, then connect an Edge between uu and vv. Now __stdcall wants you to find how many Edges there are in total.

If you fail to complete the task, then __stdcall will make you suffer a bit, and you will get no score for this test case.

Input Format

One line with six integers: nn, aa, bb, cc, dd, x0x_0.

nn is the number of points. The weight of each point needs to be generated in the following way.

You need to use aa, bb, cc, dd, and x0x_0 to generate an array x. The generation method is:

xi=(axi12+bxi1+c)moddx_i = (ax_{i-1}^2 + bx_{i-1} + c) \bmod d

xix_i is the weight of the ii-th point. The point indices are from 11 to nn.

Output Format

Output one integer, representing the total number of Edges.

8 98 24 20 100 44

12

1000 952537 601907 686180 1000000 673601

249711

Hint

Let vv denote the maximum value among the weights.

For the first 20%20\% of the data, n10n \le 10.

For the first 40%40\% of the data, n100n \le 100.

For the first 60%60\% of the data, n1000n \le 1000.

For the first 80%80\% of the data, n1×106n \le 1 \times 10^6.

For the first 90%90\% of the data, v1×106v \le 1 \times 10^6.

For 100%100\% of the data, n1×107v1×109n \le 1 \times 10^7,v \le 1 \times 10^9.

It is guaranteed that aa, bb, cc, dd, and x0x_0 are all non-negative integers within int.

Translated by ChatGPT 5