結果

問題 No.1884 Sequence
ユーザー Soham ChaudhuriSoham Chaudhuri
提出日時 2022-03-25 22:05:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,477 bytes
コンパイル時間 4,021 ms
コンパイル使用メモリ 246,004 KB
実行使用メモリ 14,132 KB
最終ジャッジ日時 2024-04-22 06:46:32
合計ジャッジ時間 8,493 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 2 ms
6,944 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 135 ms
14,000 KB
testcase_11 AC 142 ms
14,056 KB
testcase_12 AC 11 ms
6,940 KB
testcase_13 AC 11 ms
6,944 KB
testcase_14 AC 12 ms
6,940 KB
testcase_15 AC 60 ms
8,580 KB
testcase_16 AC 110 ms
14,000 KB
testcase_17 AC 32 ms
6,940 KB
testcase_18 AC 48 ms
9,008 KB
testcase_19 AC 43 ms
8,448 KB
testcase_20 AC 49 ms
6,944 KB
testcase_21 AC 34 ms
6,944 KB
testcase_22 AC 60 ms
8,456 KB
testcase_23 AC 112 ms
14,132 KB
testcase_24 AC 109 ms
13,964 KB
testcase_25 AC 108 ms
14,004 KB
testcase_26 AC 110 ms
13,964 KB
testcase_27 RE -
testcase_28 AC 12 ms
6,944 KB
testcase_29 AC 13 ms
6,940 KB
testcase_30 AC 13 ms
6,940 KB
testcase_31 AC 47 ms
7,176 KB
testcase_32 WA -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 51 ms
6,940 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 81 ms
10,672 KB
testcase_42 AC 82 ms
10,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3,unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;

#define ll               long long int
#define loop(a,b,i)      for(long long int i=a;i<b;i++)
#define loopr(a,b,i)     for(long long int i=a;i>=b;i--)
#define cn               continue;
#define pb               push_back
#define db               double
#define mp               make_pair
#define sz(x)            (ll)((x).size())
#define endl             "\n"
#define lb               lower_bound
#define ub               upper_bound
#define f                first
#define se               second
#define vll              vector<ll>
#define pll              pair<ll,ll>
#define vpll             vector< pair<ll,ll> >
#define all(x)           x.begin(),x.end()
#define print(a,n)       for(ll i=0; i<n; i++) cout<<a[i]<<" "; cout<<endl;
#define pi               3.14159265358979323846
#define quick            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update > pbds;

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MAX = 8000000000000000064LL;
const ll MIN = -8000000000000000064LL;
ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}
ll gcd(ll a,ll b) {if(b==0)return a; return gcd(b,a%b);}
ll lcm(ll x, ll y) { ll res = x / gcd(x, y); return (res * y);}
// ll nCr(ll n,ll r){ll ans=fact[n]; ans*=mod_inv(fact[n-r]);ans%=mod; ans*=mod_inv(fact[r]);ans%=mod; return ans;}
 
const ll dx[] = {-1,1,0,0,1,1,-1,-1};
const ll dy[] = {0,0,1,-1,-1,1,-1,1};
 
bool isprime(ll n) {  
    if(n<=1) return false; 
    if(n==2) return true;
    if(n%2==0 and n!=2) return false;
    for(ll i=2;i<=sqrt(n);i++) 
        if(n%i==0) 
            return false; 
    return true; 
} 
 
bool isPowerOfTwo(ll n){
   if(n==0) return false; 
   return (ceil(log2(n)) == floor(log2(n)));  
}

signed main() 
{ quick; 
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif 
    
    int tc = 1;
    // cin >> tc; 
    loop(0,tc,Q)
    {       
        // cout << "Case #" << Q+1 << ": ";
        ll n; cin >> n;
        ll cnt = 0;
        vll v;
        unordered_map<ll,ll> m;
        loop(0, n, i) {
            ll x; cin >> x;
            if(x == 0) cnt++;
            else {
                m[x]++;
                v.pb(x);
            }
        }
        sort(all(v));
        if(sz(v) == 1) {
            cout << "Yes\n";
            continue;
        }
        ll diff = 0, g = 0;
        loop(1, sz(v), i) {
            diff = v[i] - v[i-1];
            if(g == 0) g = diff;
            else g = gcd(g, diff);
        }
        ll res = ((v.back() - v[0]) / g) + 1 - (sz(v));
        if(cnt < res) cout << "No\n";
        else cout << "Yes\n";
    }
        
 
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
return 0;
}
0