結果
| 問題 |
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 Fraction
def solve(a: Fraction, b: Fraction) -> bool:
if b == 0:
return True
if b < 0:
a = 1 / a
b = -b
if not a.is_integer():
return False
ok = a.numerator
ng = 0
while ok - ng > 1:
mid = (ok + ng) // 2
if mid**b.denominator >= a:
ok = mid
else:
ng = mid
return ok**b.denominator == a.numerator
a, b = map(Fraction, input().split())
print("Yes" if solve(a, b) else "No")