結果

問題 No.983 Convolution
ユーザー chielochielo
提出日時 2020-02-11 14:03:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 201,260 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 14:50:55
合計ジャッジ時間 4,036 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 10 ms
6,548 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 26 ms
6,548 KB
testcase_18 AC 6 ms
6,548 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 22 ms
6,548 KB
testcase_22 AC 7 ms
6,548 KB
testcase_23 AC 15 ms
6,548 KB
testcase_24 AC 5 ms
6,548 KB
testcase_25 AC 4 ms
6,548 KB
testcase_26 AC 11 ms
6,548 KB
testcase_27 AC 8 ms
6,548 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,548 KB
testcase_34 AC 2 ms
6,548 KB
testcase_35 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 : -1);
    return 0;
}
0