結果
問題 | No.983 Convolution |
ユーザー | baLoon8128 |
提出日時 | 2022-04-24 10:48:49 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 947 bytes |
コンパイル時間 | 3,549 ms |
コンパイル使用メモリ | 226,444 KB |
実行使用メモリ | 8,664 KB |
最終ジャッジ日時 | 2023-09-08 03:50:57 |
合計ジャッジ時間 | 7,412 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
8,496 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
#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; }