結果

問題 No.983 Convolution
ユーザー koi_kotyakoi_kotya
提出日時 2020-02-11 14:29:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 171,228 KB
実行使用メモリ 18,932 KB
最終ジャッジ日時 2024-04-08 15:03:37
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
18,932 KB
testcase_01 AC 8 ms
18,932 KB
testcase_02 AC 8 ms
18,932 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 28 ms
18,932 KB
testcase_14 AC 29 ms
18,932 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 17 ms
18,932 KB
testcase_19 AC 41 ms
18,932 KB
testcase_20 AC 61 ms
18,932 KB
testcase_21 AC 64 ms
18,932 KB
testcase_22 WA -
testcase_23 AC 34 ms
18,932 KB
testcase_24 AC 14 ms
18,932 KB
testcase_25 AC 13 ms
18,932 KB
testcase_26 AC 24 ms
18,932 KB
testcase_27 AC 21 ms
18,932 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 9 ms
18,932 KB
testcase_34 AC 8 ms
18,932 KB
testcase_35 AC 8 ms
18,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll gcd(ll a,ll b) {
    while (b) {
        a %= b;
        swap(a,b);
    }
    return a;
}

int main() {
    int n;cin >> n;
    vector<ll> a(1000000),c;
    for (int i = 0;i < n;++i) cin >> a[i];
    c = a;
    // for (int i = 0;i < 20;++i) if ((n>>i)&1) b = i;
    for (int i = 0;i < 19;++i) for (int j = 0;j < n;++j) if (!(j&(1<<i)) && c[j] > -1) {
        if (c[i|(1<<i)] > -1) c[j] += c[i|(1<<i)];
        else c[j] = -1;
    }
    ll ans = 0;
    for (int i = 0;i < n;++i) if (a[i] > -1) ans = gcd(ans,gcd(ans,a[i])*gcd(ans,c[i]));
    if (ans == 0) cout << -1 << endl;
    else cout << ans << endl;
}
0