結果

問題 No.983 Convolution
ユーザー chocopuuchocopuu
提出日時 2020-02-11 14:33:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,244 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 170,088 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 15:05:34
合計ジャッジ時間 3,828 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 AC 51 ms
6,548 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 55 ms
6,548 KB
testcase_13 AC 21 ms
6,548 KB
testcase_14 AC 25 ms
6,548 KB
testcase_15 WA -
testcase_16 AC 32 ms
6,548 KB
testcase_17 WA -
testcase_18 AC 10 ms
6,548 KB
testcase_19 AC 33 ms
6,548 KB
testcase_20 AC 59 ms
6,548 KB
testcase_21 AC 56 ms
6,548 KB
testcase_22 AC 12 ms
6,548 KB
testcase_23 AC 33 ms
6,548 KB
testcase_24 AC 9 ms
6,548 KB
testcase_25 AC 7 ms
6,548 KB
testcase_26 AC 22 ms
6,548 KB
testcase_27 AC 17 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"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

#define ull unsigned long long

ull gcd(ull x,ull y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int lcm(int x, int y)
{
	return (x * y / gcd(x, y));
}

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	vector<int>ok(N);
	REP(i,N){
		cin >> a[i];
		if(a[i] == -1)ok[i] = 1;
	}
	RREP(i,N){
		for(long long j = 0;j < 20;j++){
			if(i&(1ll<<j)){
				if(ok[i])ok[i^(1<<j)] = 1;
				else a[i^(1ll<<j)]+=a[i];
			}
		}
	}
	ull g = -1;
	REP(i,N){
		if(ok[i])continue;
		if(g == -1)g = (ull)a[i] * a[i];
		else g = gcd(g,(ull)a[i] * a[i]);
	}
	if(g == -1)cout << -1 << endl;
	else cout << g << endl;
}
0