結果
| 問題 | 
                            No.983 Convolution
                             | 
                    
| コンテスト | |
| ユーザー | 
                             koi_kotya
                         | 
                    
| 提出日時 | 2020-02-11 14:29:01 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,061 bytes | 
| コンパイル時間 | 1,559 ms | 
| コンパイル使用メモリ | 170,744 KB | 
| 実行使用メモリ | 19,040 KB | 
| 最終ジャッジ日時 | 2024-10-01 07:39:45 | 
| 合計ジャッジ時間 | 3,955 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 WA * 19 | 
ソースコード
#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;
}
            
            
            
        
            
koi_kotya