結果
| 問題 |
No.983 Convolution
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-24 10:48:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 947 bytes |
| コンパイル時間 | 3,797 ms |
| コンパイル使用メモリ | 228,500 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-06-25 21:03:24 |
| 合計ジャッジ時間 | 7,480 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)
ll gcd(ll x, ll y) {
if (x > y) swap(x, y);
return x == 0 ? y : gcd(y % x, x);
}
int main() {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i];
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j < n; j++) {
if (i & j) {
if (a[i ^ j] < 0 || a[j] < 0) {
a[i ^ j] = -1;
} else {
a[i ^ j] += a[j];
}
}
}
}
ll r = 0;
rep(i, n) {
if (a[i] >= 0) {
r = gcd(r, a[i] * a[i]);
}
}
cout << (r == 0 ? -1 : r) << endl;
return 0;
}