結果
問題 | No.2954 Calculation of Exponentiation |
ユーザー |
![]() |
提出日時 | 2024-11-09 13:14:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 860 bytes |
コンパイル時間 | 3,556 ms |
コンパイル使用メモリ | 248,208 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-09 13:15:04 |
合計ジャッジ時間 | 5,101 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 5 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/math> void solve() { double A, B; std::cin >> A >> B; int a = A * 10000, b = B * 10000; 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; }