結果
| 問題 | No.2954 Calculation of Exponentiation |
| コンテスト | |
| ユーザー |
Today03
|
| 提出日時 | 2024-11-08 21:55:26 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,022 bytes |
| 記録 | |
| コンパイル時間 | 3,014 ms |
| コンパイル使用メモリ | 342,676 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-09 01:29:55 |
| 合計ジャッジ時間 | 4,274 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 10;
const ll INFL = 4e18;
map<int, int> pf(ll x) {
map<int, int> ret;
for (ll i = 2; i * i <= x; i++) {
if (x % i != 0) continue;
int c = 0;
while (x % i == 0) {
x /= i;
c++;
}
ret[i] = c;
}
if (x > 1) ret[x] = 1;
return ret;
}
int main() {
string A, B;
cin >> A >> B;
A.erase(ranges::find(A, '.'));
B.erase(ranges::find(B, '.'));
ll aup = stoi(A), bup = stoll(B);
ll alo = 10000, blo = 10000;
{
ll ga = gcd(aup, alo), gb = gcd(bup, blo);
aup /= ga;
alo /= ga;
bup /= gb;
blo /= gb;
}
auto p_aup = pf(aup), p_alo = pf(alo);
for (auto [k, v] : p_alo) p_aup[k] -= v;
bool ans = true;
for (auto [k, v] : p_aup) {
v *= bup;
if (v % blo != 0) ans = false;
v /= blo;
if (v < 0) ans = false;
}
puts(ans ? "Yes" : "No");
}
Today03