結果
問題 | No.2954 Calculation of Exponentiation |
ユーザー |
|
提出日時 | 2024-11-08 22:27:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 369 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-08 22:27:47 |
合計ジャッジ時間 | 2,604 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
from fractions import Fractiondef solve(a: Fraction, b: Fraction) -> bool:if b == 0:return Trueif b < 0:a = 1 / ab = -bif not a.is_integer():return Falseok = a.numeratorng = 0while ok - ng > 1:mid = (ok + ng) // 2if mid**b.denominator >= a:ok = midelse:ng = midreturn ok**b.denominator == a.numeratora, b = map(Fraction, input().split())print("Yes" if solve(a, b) else "No")