結果
問題 | No.2954 Calculation of Exponentiation |
ユーザー |
👑 |
提出日時 | 2024-05-21 15:48:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,311 bytes |
コンパイル時間 | 1,853 ms |
コンパイル使用メモリ | 202,164 KB |
最終ジャッジ日時 | 2025-02-21 16:24:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h>#define rep(i,n) for(int i=0;i<n;i++)using namespace std;// Arranged From "https://github.com/atcoder/live_library/blob/master/prime.cpp"struct Sieve {int n;vector<int> f, primes;Sieve(int n=1):n(n), f(n+1) {f[0] = f[1] = -1;for (long long i = 2; i <= n; ++i) {if (f[i]) continue;primes.push_back(i);f[i] = i;for (long long j = i*i; j <= n; j += i) {if (!f[j]) f[j] = i;}}}vector<pair<int,int>> factor(int x) {vector<pair<int,int>> res;for (int p : primes) {int y = 0;while (x%p == 0) x /= p, ++y;res.emplace_back(p,y);}if (x != 1) res.emplace_back(x,1);return res;}};long long INPUT(){string s;cin >> s;int n = s.size();long long res = 0;bool minus = false;rep(i, n){if(s[i] == '-'){minus = true;continue;}if(s[i] != '.'){res *= 10;res += s[i] - '0';}}if(minus) res *= -1;return res;}int solve(){long long a = INPUT();long long b = INPUT();Sieve sieve(100005);auto f = sieve.factor(a);for(auto& [p, num] : f){if(p == 2) num -= 4;if(p == 5) num -= 4;}string ans = "Yes";for(auto [p, num] : f){if(num * b < 0) ans = "No";if(num * b % 10000 != 0) ans = "No";}cout << ans << "\n";return 0;}int main(){solve();return 0;}