結果
問題 | No.983 Convolution |
ユーザー |
![]() |
提出日時 | 2020-02-11 15:32:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 478 ms |
コンパイル使用メモリ | 57,852 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 07:58:25 |
合計ジャッジ時間 | 1,665 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <iostream> #include <set> #define llint long long using namespace std; llint n; llint a[1<<18]; void zeta_transform(llint a[], int n) { int S = 1<<n; for(int i = 0; i < n; i++){ for(int j = 0; j < S; j++){ if(!(j&(1<<i))) a[j] += a[j^(1<<i)]; } } } void moebius_transform(llint a[], int n) { int S = 1<<n; for(int i = 0; i < n; i++){ for(int j = 0; j < S; j++){ if(!(j&(1<<i))) a[j] -= a[j^(1<<i)]; } } } llint gcd(llint a, llint b) { if(b == 0) return a; return gcd(b, a%b); } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0; i < n; i++) cin >> a[i], a[i] = max(a[i], 0LL); llint ans = 0; for(int i = 0; i < n; i++) ans = gcd(ans, a[i]); if(ans == 0) cout << -1 << endl; else cout << ans*ans << endl; return 0; }