結果
| 問題 | 
                            No.983 Convolution
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Strorkis
                         | 
                    
| 提出日時 | 2020-02-11 14:48:13 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 390 bytes | 
| コンパイル時間 | 450 ms | 
| コンパイル使用メモリ | 62,976 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-01 07:45:36 | 
| 合計ジャッジ時間 | 2,237 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 WA * 16 | 
ソースコード
#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;
}
            
            
            
        
            
Strorkis