問題一覧 > 通常問題

No.983 Convolution

レベル : / AI推定難易度 : 1950 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 73
作問者 : tubuann1 / テスター : beet
お気に入りにしたユーザー ProblemId : 3874 / 自分の提出
問題文最終更新日: 2020-02-11 19:01:29
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 236 (順位表) の他の問題:

Problem Statement

There is a sequence $A$ of positive integers consisting of $N$ terms, from the $0$-th term to the $N-1$-th term.
However, the values of some $0$ or more of the terms can be chosen freely.
Define a sequence $B$ of positive integers consisting of $N$ terms, from the $0$-th term to the $N-1$-th term, as follows.

    $\displaystyle B_k = \sum_{i\& j=k} (A_i \times A_j)$
$\& $ denotes bitwise and.
The greatest common divisor of $B$ is defined as the largest positive integer that divides the values of all terms of $B$.
Find the maximum possible value of the greatest common divisor of $B$ when the values of the terms of $A$ are chosen optimally.
However, if the maximum value of the greatest common divisor does not exist, output $-1$.

Input

$N$
$A_0\ A_1\ \ldots A_{N-1}$

$1 \leq N \leq 2 \times 10^5$
$1 \leq A_i \leq 10^9$ or $A_i=-1$
The value of the $i$-th term can be chosen freely among positive integers if and only if $A_i=-1$
All inputs are integers

Output

Output the answer in one line.

Sample

Sample 1
Input
3
-1 -1 -1
Output
-1

For any arbitrarily large integer $M$, there is a way to choose the terms that makes the greatest common divisor larger than $M$.

Sample 2
Input
5
7 9 3 5 1
Output
1

Sample 3
Input
5
-1 54 -1 12 -1
Output
36

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