QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 1024 MB Puntuación total: 14

#5844. 去随机化 (De-RNG-ed)

Estadísticas

我想建立一个在线扑克网站。该系统中一个非常重要的组件是随机数生成器。它需要足够快且足够随机。这是我想出的一个折中方案。我需要一种生成长度不超过 $D$ 的随机数的方法。我的计划是选择一个质数 $P \le 10^D$。我还要选择非负整数 $A$ 和 $B$。最后,我将选择一个介于 $0$ 到 $P-1$(含)之间的整数种子 $S$。

为了输出我的伪随机数序列,我将首先输出 $S$,然后按照以下方式计算 $S$ 的新值:

S := (A*S + B) mod P.

然后,我将输出 $S$ 的新值作为序列中的下一个数字,并再次使用相同的公式更新 $S$。我可以根据需要重复此过程任意多次。

你认为这是一个好的随机数生成器吗?你能写一个程序,输入由我的随机数生成器生成的序列中的 $K$ 个连续元素,并打印出该序列的下一个元素吗?

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例的第一行包含 $D$ 和 $K$。下一行包含由上述类型的随机数生成器生成的 $K$ 个连续元素。

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是用例编号(从 1 开始),$y$ 是序列中的下一个数字,如果答案不唯一,则输出字符串 "I don't know."。

样例

输入格式 1

3
2 10
0 1 2 3 4 5 6 7 8 9
3 1
13
1 5
6 6 6 6 6

输出格式 1

Case #1: 10
Case #2: I don't know.
Case #3: 6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.