結果
問題 | No.2954 Calculation of Exponentiation |
ユーザー |
![]() |
提出日時 | 2024-11-13 21:10:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,111 bytes |
コンパイル時間 | 571 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 53,736 KB |
最終ジャッジ日時 | 2024-11-13 21:10:37 |
合計ジャッジ時間 | 3,246 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
def factorization(n):arr = []temp = nfor i in range(2, int(-(-n**0.5//1))+1):if temp%i==0:cnt=0while temp%i==0:cnt+=1temp //= iarr.append([i, cnt])if temp!=1:arr.append([temp, 1])return arrA, B = input().split()A1, A2 = A.split(".")B1, B2 = B.split(".")flag = 1if B1[0] == "-":flag = 0A1, A2, B1, B2 = int(A1), int(A2), int(B1), int(B2)if flag:if B1 == 0 and B2 == 0:print("Yes")exit()if A2:print("No")exit()if B2 == 0:print("Yes")exit()L = factorization(A1)for a, v in L:if v * (B1 * 10000 + B2) % 10000:print("No")exit()print("Yes")else:top = 10000down = 10000 * A1 + A2if top % down:print("No")exit()A1 = top // downL = factorization(A1)for a, v in L:if v * (B1 * 10000 + B2) % 10000:print("No")exit()print("Yes")