結果

問題 No.1884 Sequence
ユーザー akasinnakasinn
提出日時 2022-03-25 22:58:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 171,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 07:49:00
合計ジャッジ時間 3,523 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 14 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 9 ms
6,944 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 7 ms
6,940 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 8 ms
6,944 KB
testcase_24 AC 8 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 29 ms
6,940 KB
testcase_28 AC 15 ms
6,944 KB
testcase_29 AC 25 ms
6,944 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 8 ms
6,944 KB
testcase_34 AC 8 ms
6,944 KB
testcase_35 AC 8 ms
6,940 KB
testcase_36 AC 8 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 9 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//ユークリッドの互除法(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--){
    int 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));
  }
  int needs=A.at(n-1)/gcd+1-n;
  if(needs<=zero)cout<<"Yes\n";else cout<<"No\n";
  //cout<<gcd;
  return 0;
}



0