結果
| 問題 |
No.983 Convolution
|
| コンテスト | |
| ユーザー |
Strorkis
|
| 提出日時 | 2020-02-11 15:04:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 396 bytes |
| コンパイル時間 | 539 ms |
| コンパイル使用メモリ | 64,136 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 07:49:26 |
| 合計ジャッジ時間 | 2,220 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <iostream>
using namespace std;
int gcd(int a, int b) {
int r = a % b;
return r ? gcd(b, r) : b;
}
int main() {
int n; cin >> n;
bool flag = false;
int res = -1;
for (int i = 0; i < n; i++) {
int a; cin >> a;
if (a < 0) continue;
if (!flag) {
flag = true;
res = a;
}
res = gcd(res, a);
}
cout << (flag ? 1LL * res * res : res) << endl;
}
Strorkis