問題一覧 > 通常問題

No.97 Query for the Maximum Value

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 72
作問者 : anta
お気に入りにしたユーザー ProblemId : 105 / 自分の提出
問題文最終更新日: 2026-06-26 06:08:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 57 (順位表) の他の問題:

Problem Statement

You are given a sequence $A$ of length $N$. Each query gives $q_i$; find the maximum value in $\{ {(q_i \times a)} \bmod {100003} \mid a \in A \}$. Here, $x \bmod y$ denotes the remainder when $x$ is divided by $y$.

$A$ is not given directly. Instead, generate it in a way equivalent to calling generateA in the following code.

unsigned xor128_x = 123456789, xor128_y = 362436069, xor128_z = 521288629, xor128_w = 88675123;
unsigned xor128() {
	unsigned t = xor128_x ^ (xor128_x << 11);
	xor128_x = xor128_y; xor128_y = xor128_z; xor128_z = xor128_w;
	return xor128_w = xor128_w ^ (xor128_w >> 19) ^ (t ^ (t >> 8));
}
void generateA(int N, int A[]) {
    for(int i = 0; i < N; ++ i)
        A[i] = xor128() % 100003;
}

Input

$N$ $Q$
$q_1$
$\vdots$
$q_Q$

The first line contains two space-separated integers $1 \le N, Q \le 100003$. Each of the following $Q$ lines, starting from the second line, contains an integer $0 \le q_i < 100003$ representing a query. Note that the sequence $A$ is not given as input and must be generated as in the code above.

Output

For each query, output the answer followed by a newline.

Sample

Sample 1
Input
3 3
1
100
100002
Output
97597
73872
23262

Here $A = [76741, 85364, 97597]$. For the respective queries, the remainders of $1 \times 97597$, $100 \times 76741$, and $100002 \times 76741$ divided by 100003 are the maximum values.

Sample 2
Input
100003 3
1
2
100002
Output
100002
100002
100001

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。