結果
問題 |
No.983 Convolution
|
ユーザー |
![]() |
提出日時 | 2020-02-11 15:31:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 524 ms |
コンパイル使用メモリ | 58,388 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 07:58:23 |
合計ジャッジ時間 | 1,892 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 27 WA * 6 |
ソースコード
#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) ans = -1; cout << ans*ans << endl; return 0; }