結果

問題 No.1884 Sequence
ユーザー akasinnakasinn
提出日時 2022-03-26 12:54:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 931 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 170,176 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 05:11:16
合計ジャッジ時間 6,574 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 146 ms
6,948 KB
testcase_11 AC 146 ms
6,944 KB
testcase_12 AC 25 ms
6,944 KB
testcase_13 AC 27 ms
6,940 KB
testcase_14 AC 27 ms
6,944 KB
testcase_15 AC 90 ms
6,940 KB
testcase_16 AC 145 ms
6,944 KB
testcase_17 AC 60 ms
6,940 KB
testcase_18 AC 89 ms
6,940 KB
testcase_19 AC 70 ms
6,940 KB
testcase_20 AC 75 ms
6,940 KB
testcase_21 AC 57 ms
6,940 KB
testcase_22 AC 82 ms
6,944 KB
testcase_23 AC 144 ms
6,944 KB
testcase_24 AC 146 ms
6,940 KB
testcase_25 AC 138 ms
6,940 KB
testcase_26 AC 144 ms
6,940 KB
testcase_27 AC 32 ms
6,940 KB
testcase_28 AC 31 ms
6,940 KB
testcase_29 AC 30 ms
6,940 KB
testcase_30 AC 31 ms
6,940 KB
testcase_31 AC 73 ms
6,944 KB
testcase_32 AC 135 ms
6,944 KB
testcase_33 AC 130 ms
6,944 KB
testcase_34 AC 130 ms
6,944 KB
testcase_35 AC 37 ms
6,940 KB
testcase_36 AC 96 ms
6,944 KB
testcase_37 AC 131 ms
6,940 KB
testcase_38 AC 117 ms
6,940 KB
testcase_39 AC 52 ms
6,940 KB
testcase_40 AC 57 ms
6,940 KB
testcase_41 AC 117 ms
6,940 KB
testcase_42 AC 118 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*yukicoder No.1884 Sequence*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

//ユークリッドの互除法(0<x<y)
ll gojyohou(ll x,ll y){
  ll a=y%x;
  if(a){//a!=0
    return gojyohou(a,x);
  }else{//a==0
    return x;
  }
}

int main(){
  int n,zero=0;
  vector<ll> A(0);
  cin>>n;
  while(n--){
    ll i;
    cin>>i;
    if(i){//i!=0
      A.push_back(i);
    }else{//i==0
      zero++;
    }
  }
  n=A.size();
  if(n<3){
    printf("Yes\n");
    return 0;
  }
  sort(A.begin(),A.end());//小さい順に
  for(int i=1;i<n;i++){
    if(A.at(i-1)==A.at(i)){
      if(A.at(0)==A.at(n-1))cout<<"Yes\n";
      else cout<<"No\n";
      return 0;
    }
  }
  for(int i=1;i<n;i++){
    A.at(i)-=A.at(0);
  }
  ll gcd=gojyohou(A.at(1),A.at(2));
  for(int i=3;i<n;i++){
    gcd=gojyohou(gcd,A.at(i));
  }
  ll needs=A.at(n-1)/gcd+1-n;
  if(needs<=zero)cout<<"Yes\n";else cout<<"No\n";
  //cout<<gcd;
  return 0;
}
0