結果

問題 No.1884 Sequence
ユーザー ytqm3ytqm3
提出日時 2022-04-07 13:33:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 5,517 ms
コンパイル使用メモリ 205,584 KB
実行使用メモリ 7,800 KB
最終ジャッジ日時 2023-08-18 17:23:43
合計ジャッジ時間 8,880 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 118 ms
7,692 KB
testcase_11 AC 119 ms
7,700 KB
testcase_12 AC 22 ms
4,376 KB
testcase_13 AC 24 ms
4,380 KB
testcase_14 AC 22 ms
4,532 KB
testcase_15 AC 72 ms
6,124 KB
testcase_16 AC 135 ms
7,796 KB
testcase_17 AC 54 ms
5,552 KB
testcase_18 AC 74 ms
6,412 KB
testcase_19 AC 56 ms
6,000 KB
testcase_20 AC 60 ms
5,864 KB
testcase_21 AC 49 ms
5,372 KB
testcase_22 AC 70 ms
6,076 KB
testcase_23 AC 141 ms
7,748 KB
testcase_24 AC 141 ms
7,728 KB
testcase_25 AC 112 ms
7,652 KB
testcase_26 AC 113 ms
7,692 KB
testcase_27 AC 25 ms
4,612 KB
testcase_28 AC 27 ms
4,860 KB
testcase_29 AC 26 ms
4,556 KB
testcase_30 AC 26 ms
4,660 KB
testcase_31 AC 58 ms
5,648 KB
testcase_32 AC 107 ms
7,648 KB
testcase_33 AC 105 ms
6,600 KB
testcase_34 AC 102 ms
6,820 KB
testcase_35 AC 34 ms
5,056 KB
testcase_36 AC 76 ms
5,552 KB
testcase_37 AC 103 ms
7,696 KB
testcase_38 AC 94 ms
7,800 KB
testcase_39 AC 41 ms
5,508 KB
testcase_40 AC 48 ms
5,620 KB
testcase_41 AC 96 ms
6,904 KB
testcase_42 AC 110 ms
7,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using i64=long long;

int main(){
  i64 N;
  cin>>N;
  vector<i64> a(N);
  for(auto& v:a){
    cin>>v;
  }
  vector<i64> A;
  for(auto& v:a){
    if(v!=0){
      A.emplace_back(v);
    }
  }
  if(A.size()==0){
    puts("Yes");
    return 0;
  }
  int n=A.size();
  sort(A.begin(),A.end());
  i64 now=1,k=A.back()-A[0];
  if(k==0){
    puts("Yes");
    return 0;
  }
  auto B=A;
  if(unique(B.begin(),B.end())!=B.end()){
    puts("No");
    return 0;
  }
  for(int i=1;i<n-1;++i){
    i64 t=k/gcd(k,A[i]-A[0]);
    if(t/gcd(now,t)<=(N-1)/now){
      now=lcm(t,now);
    }
    else{
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
0