結果
| 問題 |
No.983 Convolution
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2020-02-11 11:10:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 744 bytes |
| コンパイル時間 | 2,327 ms |
| コンパイル使用メモリ | 194,812 KB |
| 最終ジャッジ日時 | 2025-01-08 23:27:06 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
struct FastIO{
FastIO(){
cin.tie(0);
ios::sync_with_stdio(0);
}
}fastio_beet;
//INSERT ABOVE HERE
signed main(){
int n;
cin>>n;
assert(1<=n && n<=2e5);
vector<int> as(n);
for(int i=0;i<n;i++) cin>>as[i];
for(int a:as)
assert((1<=a && a<=1e9) || a==-1);
vector<int> bs;
for(int a:as)
if(a>0) bs.emplace_back(a);
if(bs.empty()) drop(-1);
int g=bs[0];
for(int b:bs)
g=__gcd(g,b);
cout<<(long long)g*g<<endl;
return 0;
}
beet