結果
問題 | No.2954 Calculation of Exponentiation |
ユーザー |
|
提出日時 | 2024-11-08 21:57:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 994 bytes |
コンパイル時間 | 380 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 80,292 KB |
最終ジャッジ日時 | 2024-11-08 21:57:29 |
合計ジャッジ時間 | 5,655 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
def make_divisors(n):lower_divisors , upper_divisors = [], []i = 1while i*i <= n:if n % i == 0:lower_divisors.append(i)if i != n // i:upper_divisors.append(n//i)i += 1return lower_divisors + upper_divisors[::-1]import math,decimala,b = map(decimal.Decimal,input().split())if b == decimal.Decimal('0') or a == decimal.Decimal('0') or a == decimal.Decimal('1') or a == decimal.Decimal('-1'):exit(print('Yes'))if b < decimal.Decimal('0'):q = decimal.Decimal('1000000') / (decimal.Decimal('1000000') * a)if q == math.floor(q):print('Yes')exit()exit(print('No'))if a != math.floor(a):print('No')exit()a = int(a)b = abs(b)for i in make_divisors(a):for j in range(30):if pow(i,j) == a:z = decimal.Decimal(j) * bif z == math.floor(z):exit(print('Yes'))if pow(i,j) > a:breakprint('No')