#P7121. Ame 和 Gura 的奇妙探险

    ID: 6141 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学2020Special JudgeO2优化扩展欧几里德,扩欧

Ame 和 Gura 的奇妙探险

Description

Ame knows that as long as she can find the seed used to initialize the MT19937 engine, she can figure out how to obtain a Silk Touch pickaxe. So she traveled around the world, and with her clever detective mind, she worked out the first NN random numbers generated right after the MT19937 engine was initialized (note: here NN is a parameter in the MT19937 engine). Now she gives you these NN random numbers, hoping that you can deduce the seed used to initialize the MT19937 engine (0seed<2320\le\text{seed}<2^{32}). Note that Mivicraft does not use the standard MT19937 engine: some parameters are changed compared with the paper, and Ame has appended them to the input. Please help Ame!

Kind Mivik has prepared a simple and easy-to-understand MT19937 implementation for you. Please check it in the attachment.

Input Format

The first line contains 10 non-negative integers, corresponding to the 10 parameters in MT19937: NN, MM, AA, UU, SS, BB, TT, CC, LL, and FF.

The next NN lines each contain one non-negative integer, representing in order the NN random numbers generated right after the MT19937 engine was initialized.

Output Format

Output one non-negative integer in a single line, representing the seed used when initializing the MT19937 engine. The testdata guarantees that there is a solution. If there are multiple solutions, you only need to output any one of them.

见 sample/1.in
见 sample/1.out
见 sample/2.in
见 sample/2.out

Hint

Sample Explanation #1

All 10 parameters use the standard MT19937 parameters, and the seed is 233333. That is, you can generate the same random number sequence with the following program:

#include <iostream>
#include <random>

std::mt19937 engine(233333);
int main() {
	for (int i = 0; i < 624; ++i)
		std::cout << engine() << std::endl;
	return 0;
}

Constraints

This problem uses bundled tests.

For all data, 10M<N2×10510\le M<N\le 2\times 10^5, 0A,B,C<2320\le A,B,C<2^{32}, 1U,S,T,L311\le U,S,T,L\le 31, 1F<2321\le F<2^{32}, and FF is guaranteed to be odd.

The specific limits for each subtask are shown in the table below:

Subtask ID Points Special Constraints
1 20 The seed is less than or equal to 10001000
2 30 U=S=T=L=16U=S=T=L=16, A=B=C=0A=B=C=0
3 50 None

Note: The provided files are encoded in UTF-8. Please use an editor that can recognize this encoding to open them.

Backup link for attachment download: Baidu Netdisk Extraction code: jf9e

Translated by ChatGPT 5