結果
| 問題 |
No.1250 汝は倍数なりや?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-10 19:59:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,154 bytes |
| コンパイル時間 | 1,795 ms |
| コンパイル使用メモリ | 176,916 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-20 16:53:44 |
| 合計ジャッジ時間 | 4,823 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 TLE * 1 -- * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;
vector<int> sieve(int n) {
vector<bool> prime(n + 1,true);
prime[0] = false;
prime[1] = false;
for (int i = 3; i * i <= n; i += 2) {
if (prime[i]) {
int j = 2;
while (i * j <= n) {
prime[i * j] = false;
j ++;
}
}
}
vector<int> ans = {2};
for (int i = 3; i < n + 1; i += 2) {
if (prime[i]) ans.push_back(i);
}
return ans;
}
vector<pair<int,int>> factorization(long long N,vector<int>& primes) {
vector<pair<int,int>> ret;
for (int p:primes) {
int power = 0;
while (N%p == 0) {
power ++;
N /= p;
}
if (power > 0) ret.emplace_back(p,power);
}
if (N > 1) ret.emplace_back(N,1);
return ret;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N,H; cin >> N >> H;
vector<ll> A(N);
rep(i,N) cin >> A[i];
auto ps = sieve(100000);
auto x = factorization(H,ps);
for (ll a:A) {
for (P &p:x) {
while (p.first > 0 && a%p.first == 0) {
p.second--;
a /= p.first;
}
}
}
bool flag = true;
for (P &p:x) {
if (p.second > 0) flag = false;
}
cout << (flag ? "YES":"NO") << '\n';
return 0;
}