結果
問題 | No.983 Convolution |
ユーザー |
![]() |
提出日時 | 2020-03-01 23:09:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 410 bytes |
コンパイル時間 | 518 ms |
コンパイル使用メモリ | 65,760 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 20:53:26 |
合計ジャッジ時間 | 3,858 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <vector>#include <iostream>using namespace std;const int inf = 1012345678;int gcd(int x, int y) {if (y == 0) return x;return gcd(y, x % y);}int main() {int N;cin >> N;int g = inf;for (int i = 0; i < N; ++i) {int x;cin >> x;if (x != -1) {if (g == inf) g = x;else g = gcd(g, x);}}if (g == inf) cout << -1 << endl;else cout << 1LL * g * g << endl;return 0;}