結果

問題 No.983 Convolution
ユーザー StrorkisStrorkis
提出日時 2020-02-11 14:48:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 390 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 63,676 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 15:11:45
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 19 ms
6,548 KB
testcase_14 AC 20 ms
6,548 KB
testcase_15 AC 35 ms
6,548 KB
testcase_16 AC 25 ms
6,548 KB
testcase_17 AC 39 ms
6,548 KB
testcase_18 AC 9 ms
6,548 KB
testcase_19 AC 29 ms
6,548 KB
testcase_20 AC 48 ms
6,548 KB
testcase_21 AC 49 ms
6,548 KB
testcase_22 AC 10 ms
6,548 KB
testcase_23 AC 24 ms
6,548 KB
testcase_24 AC 7 ms
6,548 KB
testcase_25 AC 7 ms
6,548 KB
testcase_26 AC 16 ms
6,548 KB
testcase_27 AC 13 ms
6,548 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,548 KB
testcase_34 AC 2 ms
6,548 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

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 ? res * res : res) << endl;
}
0