結果
| 問題 |
No.2954 Calculation of Exponentiation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-08 23:09:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 576 bytes |
| コンパイル時間 | 268 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 65,280 KB |
| 最終ジャッジ日時 | 2024-11-08 23:09:39 |
| 合計ジャッジ時間 | 2,724 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 RE * 1 |
ソースコード
from math import*
from collections import*
def pf(n):
a,f=defaultdict(int),2
while f*f<=n:
if n%f:f+=1
else:a[f]+=1;n//=f
if n>1:a[n]+=1
return a
a,b=input().split()
al,ar=map(int,a.split('.'))
bl,br=map(int,b.split('.'))
a=al*10000+ar
ag=gcd(a,10000)
a//=ag
aq=10000//ag
b=bl*10000+br
bg=gcd(b,10000)
b//=bg
bq=10000//bg
if b<0:
b,bg=bg,-b
if aq==bq==1:
exit(print('Yes'))
pa=pf(a)
paq=pf(aq)
for k,v in pa.items():
if v*b%bq:
exit(print('No'))
for k,v in paq.items():
if v*bq%b:
exit(print('No'))
if pa[k]*b<v*bq:
exit(print('No'))
print('Yes')