#P5495. 【模板】Dirichlet 前缀和

【模板】Dirichlet 前缀和

Description

Given a sequence a1,a2,a3,,ana_1,a_2,a_3,\dots,a_n of length nn.

Now you need to compute a sequence b1,b2,b3,,bnb_1,b_2,b_3,\dots,b_n of length nn, satisfying

bk=ikaib_k=\sum_{i|k}a_i

Due to some mysterious reasons, each bkb_k should be taken modulo 2322^{32}.

Input Format

To avoid overly large input, this problem uses a random number generator.

The input contains only one line with two integers n,seedn, seed. Here, seedseed is a 3232-bit unsigned integer used to generate the data.

Next, you need to call the random number generator nn times to generate a1ana_1 \sim a_n.

For C/C++ users, the generator template is as follows:

#define uint unsigned int
uint seed;
inline uint getnext(){
	seed^=seed<<13;
	seed^=seed>>17;
	seed^=seed<<5;
	return seed;
}

For Pascal users, the generator template is as follows:

var seed:dword;
function getnext:dword;
begin
	seed:=seed xor(seed shl 13);
	seed:=seed xor(seed shr 17);
	seed:=seed xor(seed shl 5);
	getnext:=seed;
end;

Note: All nn numbers are 3232-bit unsigned integers.

Output Format

To avoid overly large output, you only need to output one 3232-bit unsigned integer, which is the XOR sum of all bib_i.

5 1477

2608816472

Hint

In the sample, the sequence aa is $397153977, 974453892, 352446086, 334987182, 2086335567$.

The sequence bb is $397153977, 1371607869, 749600063, 1706595051, 2483489544$.

Constraints and Conventions

For 100%100\% of the testdata, 1n2×1071\leq n\leq 2\times 10^7, 0seed<2320\leq seed< 2^{32}.

Translated by ChatGPT 5