結果

問題 No.1884 Sequence
ユーザー SSRSSSRS
提出日時 2022-03-25 21:27:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 2,552 ms
コンパイル使用メモリ 198,748 KB
実行使用メモリ 8,168 KB
最終ジャッジ日時 2024-04-22 06:01:26
合計ジャッジ時間 6,065 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 25 ms
5,376 KB
testcase_13 AC 27 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 120 ms
8,040 KB
testcase_17 AC 57 ms
5,732 KB
testcase_18 WA -
testcase_19 AC 69 ms
6,020 KB
testcase_20 WA -
testcase_21 AC 54 ms
5,608 KB
testcase_22 WA -
testcase_23 AC 121 ms
8,044 KB
testcase_24 AC 121 ms
8,168 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 30 ms
5,376 KB
testcase_28 AC 29 ms
5,376 KB
testcase_29 AC 30 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 118 ms
8,040 KB
testcase_34 AC 123 ms
8,040 KB
testcase_35 AC 38 ms
5,376 KB
testcase_36 AC 89 ms
6,892 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 100 ms
7,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> B;
  for (int i = 0; i < N; i++){
    if (A[i] != 0){
      B.push_back(A[i]);
    }
  }
  if (B.size() <= 1){
    cout << "Yes" << endl;
  } else if (B == vector<long long>(B.size(), B[0])){
    cout << "Yes" << endl;
  } else {
    int M = B.size();
    long long g = 0;
    for (int i = 0; i < M - 1; i++){
      g = gcd(g, B[i + 1] - B[i]);
    }
    if (g == 0){
      cout << "No" << endl;
    } else {
      long long cnt = (B[M - 1] - B[0]) / g + 1;
      if (cnt <= N){
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
}
0