結果

問題 No.2682 Visible Divisible
ユーザー かえでかえで
提出日時 2024-03-20 21:26:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,821 bytes
コンパイル時間 4,934 ms
コンパイル使用メモリ 208,308 KB
実行使用メモリ 10,004 KB
最終ジャッジ日時 2024-03-20 21:27:15
合計ジャッジ時間 9,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
6,676 KB
testcase_01 AC 163 ms
6,676 KB
testcase_02 AC 165 ms
6,676 KB
testcase_03 AC 163 ms
6,676 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize "O3,omit-frame-pointer,inline"
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//fixed,setprecision
#include <limits.h>//INT_MAX
#include <math.h>//M_PI
#include <random>
#include <regex> // 正規表現
#include <time.h>
#include <fstream>
#include <array>
#include <bit>
#include <chrono>
#include <ranges>
#include <span>
#include <cmath>
#include <cstdint>
#include <complex>//複素数
//#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
//using mint = modint1000000007;
using mint = modint998244353;
// using mint=modint;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//const int dx[8]={1,0,-1,0,1,1,-1,-1};
//const int dy[8]={0,1,0,-1,1,-1,1,-1};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll gcd(ll x,ll y){return y? gcd(y,x%y) :x;}
vector<pair<ll,int>>factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;++i){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n%i==0){
            n/=i;
            res.back().second++;
        }
    }
    if(n!=1)res.emplace_back(n,1);
    return res;
}
ll gcd_vec(vector<ll> const &A) { // N個の要素に対する最大公約数
    int size = (int)A.size();
    long long ret = A[0];
    for (int i = 1; i < size; i++) {
        ret = gcd(ret, A[i]);
    }
    return ret;
}
int main(){
    ll n,k;
    cin>>n>>k;
    auto f=factorize(k);
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll g=gcd_vec(a);
    rep(i,n){
        a[i]/=g;
    }
    rep(j,f.size()){
        while(g%f[j].first==0){
            f[j].second--;
            g/=f[j].first;
            if(f[j].second==0)break;
        }
    }
    rep(i,n){
        rep(j,f.size()){
            while(a[i]%f[j].first==0){
                f[j].second--;
                a[i]/=f[j].first;
                if(f[j].second==0)break;
            }
        }
        bool check=true;
        rep(j,f.size()){
            if(f[j].second>0){
                check=false;
                break;
            }
        }
        if(check){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

0