結果

問題 No.983 Convolution
ユーザー StrorkisStrorkis
提出日時 2020-02-11 15:04:00
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 396 bytes
コンパイル時間 411 ms
使用メモリ 3,556 KB
最終ジャッジ日時 2022-11-24 17:59:22
合計ジャッジ時間 2,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,524 KB
testcase_01 AC 1 ms
3,424 KB
testcase_02 AC 1 ms
3,368 KB
testcase_03 AC 31 ms
3,528 KB
testcase_04 AC 31 ms
3,468 KB
testcase_05 AC 24 ms
3,528 KB
testcase_06 AC 36 ms
3,536 KB
testcase_07 AC 30 ms
3,524 KB
testcase_08 AC 7 ms
3,500 KB
testcase_09 AC 9 ms
3,556 KB
testcase_10 AC 5 ms
3,468 KB
testcase_11 AC 9 ms
3,528 KB
testcase_12 AC 31 ms
3,468 KB
testcase_13 AC 14 ms
3,552 KB
testcase_14 AC 15 ms
3,364 KB
testcase_15 AC 26 ms
3,536 KB
testcase_16 AC 19 ms
3,524 KB
testcase_17 AC 29 ms
3,476 KB
testcase_18 AC 8 ms
3,516 KB
testcase_19 AC 24 ms
3,428 KB
testcase_20 AC 40 ms
3,372 KB
testcase_21 AC 38 ms
3,428 KB
testcase_22 AC 7 ms
3,468 KB
testcase_23 AC 17 ms
3,372 KB
testcase_24 AC 5 ms
3,536 KB
testcase_25 AC 4 ms
3,524 KB
testcase_26 AC 13 ms
3,544 KB
testcase_27 AC 9 ms
3,520 KB
testcase_28 AC 28 ms
3,424 KB
testcase_29 AC 55 ms
3,528 KB
testcase_30 AC 29 ms
3,528 KB
testcase_31 AC 16 ms
3,500 KB
testcase_32 AC 30 ms
3,372 KB
testcase_33 AC 1 ms
3,432 KB
testcase_34 AC 1 ms
3,528 KB
testcase_35 AC 1 ms
3,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0