結果
| 問題 | No.983 Convolution |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-11 14:05:37 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 825 bytes |
| 記録 | |
| コンパイル時間 | 1,372 ms |
| コンパイル使用メモリ | 209,752 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-08 18:26:15 |
| 合計ジャッジ時間 | 3,128 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
const int maxn = 1e6 + 3;
int n, m;
ll a[maxn];
void fwt() {
for(int i = 1; i < m; i *= 2)
for(int j = 0; j < m; j += i * 2)
for(int k = 0; k < i; ++k)
a[j + k] += a[j + k + i];
}
void ifwt() {
for(int i = 1; i < m; i *= 2)
for(int j = 0; j < m; j += i * 2)
for(int k = 0; k < i; ++k)
a[j + k] -= a[j + k + i];
}
int main() {
scanf("%d", &n);
m = 1;
while(m < n)
m *= 2;
for(int i = 0; i < n; ++i) {
scanf("%lld", a + i);
if(a[i] == -1)
a[i] = 0;
}
fwt();
// for(int i = 0; i < m; ++i)
// a[i] *= a[i];
// ifwt();
ll ans = 0;
for(int i = 0; i < n; ++i)
ans = std::__gcd(ans, a[i]);
printf("%lld\n", ans ? ans * ans : -1);
return 0;
}