結果
問題 |
No.2954 Calculation of Exponentiation
|
ユーザー |
![]() |
提出日時 | 2024-11-09 13:35:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,946 bytes |
コンパイル時間 | 3,202 ms |
コンパイル使用メモリ | 250,792 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-11-09 13:35:24 |
合計ジャッジ時間 | 4,429 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 2 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/math> void solve() { double A, B; std::cin >> A >> B; int a = A * 10000, b = B * 10000; if (b == 0) { std::cout << "Yes\n"; } else if (b > 0) { if (a % 10000 != 0) { std::cout << "No\n"; } else { int cnt2 = 4, cnt5 = 4; while (cnt2 && b % 2 == 0) { cnt2--; b /= 2; } while (cnt5 && b % 5 == 0) { cnt5--; b /= 5; } a /= 10000; int p = 1; for (;cnt2--;) { p *= 2; } for (;cnt5--;) { p *= 5; } for (int i = 1; atcoder::pow_mod(i, p, 1 << 30) <= a; i++) { if (atcoder::pow_mod(i, p, 1 << 30) == a) { std::cout << "Yes\n"; return; } } std::cout << "No\n"; } } else { if (a > 10000) { std::cout << "No\n"; } else if (a == 10000) { std::cout << "Yes\n"; } else { if (10000 % a != 0) { std::cout << "No\n"; } else { a = 10000 / a; b *= -1; if (a % 10000 != 0) { std::cout << "No\n"; } else { int cnt2 = 4, cnt5 = 4; while (cnt2 && b % 2 == 0) { cnt2--; b /= 2; } while (cnt5 && b % 5 == 0) { cnt5--; b /= 5; } a /= 10000; int p = 1; for (;cnt2--;) { p *= 2; } for (;cnt5--;) { p *= 5; } for (int i = 1; atcoder::pow_mod(i, p, 1 << 30) <= a; i++) { if (atcoder::pow_mod(i, p, 1 << 30) == a) { std::cout << "Yes\n"; return; } } std::cout << "No\n"; } } } } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int testcases = 1; // std::cin >> testcases; for (;testcases--;) { solve(); } return 0; }