結果
| 問題 |
No.2954 Calculation of Exponentiation
|
| コンテスト | |
| ユーザー |
nono00
|
| 提出日時 | 2024-11-08 23:10:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 3,194 bytes |
| コンパイル時間 | 3,101 ms |
| コンパイル使用メモリ | 253,968 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 23:10:14 |
| 合計ジャッジ時間 | 4,138 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define rrep(i, r, l) for (ll i = (r); i-- > (l);)
#define all(x) begin(x), end(x)
template <class T>
bool chmin(T& lhs, T rhs) {
return lhs > rhs ? (lhs = rhs, true) : false;
}
template <class T>
bool chmax(T& lhs, T rhs) {
return lhs < rhs ? (lhs = rhs, true) : false;
}
struct IOIO {
IOIO() {
cin.tie(0)->sync_with_stdio(0);
}
} ioio;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
os << '(' << p.first << ", " << p.second << ')';
return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& vs) {
os << '{';
rep(i, 0, (int)vs.size()) os << vs[i] << (i + 1 == (int)vs.size() ? "" : ", ");
os << '}';
return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& vs) {
os << '{';
for (auto it = vs.begin(); it != vs.end(); it++) {
if (it != vs.begin()) {
os << ", ";
}
os << *it;
}
os << '}';
return os;
}
template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& vs) {
os << '{';
for (auto it = vs.begin(); it != vs.end(); it++) {
if (it != vs.begin()) {
os << ", ";
}
os << *it;
}
os << '}';
return os;
}
#ifdef DEBUG
void dump_func() {
cerr << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
cerr << head;
if (sizeof...(Tail) > 0) {
cerr << ", ";
}
dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" + string(#__VA_ARGS__) + "] ", dump_func(__VA_ARGS__)
#else
#define dump(...) static_cast<int>(0)
#endif
ll input() {
string s;
cin >> s;
s.erase(find(all(s), '.'));
return stoll(s);
}
void norm(ll& lhs, ll& rhs) {
ll g = gcd(abs(lhs), abs(rhs));
lhs /= g;
rhs /= g;
}
map<ll, ll> factorize(ll n) {
map<ll, ll> res;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
ll cnt = 0;
while (n % i == 0) n /= i, cnt++;
res[i] = cnt;
}
}
if (n != 1) res[n] = 1;
return res;
}
void solve() {
auto a = input();
ll b = 10000;
auto c = input();
ll d = 10000;
norm(a, b);
norm(c, d);
auto A = factorize(a);
auto B = factorize(b);
map<ll, ll> ans;
bool ok = true;
for (auto [p, e]: A) {
if (e % d != 0) {
ok = false;
}
}
for (auto [p, e]: B) {
if (e % d != 0) {
ok = false;
}
}
for (auto [p, e]: A) {
ans[p] += c * e + (d == 1 ? 0 : e / d);
}
for (auto [p, e]: B) {
ans[p] -= c * e + (d == 1 ? 0 : e / d);
}
for (auto [p, e]: ans) {
if (e < 0) ok = false;
}
dump(a, b, c, d);
cout << (ok || c == 0 ? "Yes" : "No") << '\n';
}
int main() {
int t = 1;
while (t--) solve();
}
nono00