結果

問題 No.2954 Calculation of Exponentiation
コンテスト
ユーザー vwxyz
提出日時 2024-11-09 03:15:30
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 227 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 59,648 KB
最終ジャッジ日時 2026-05-09 07:51:50
合計ジャッジ時間 4,707 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
def Factorize(N):
    assert N>=1
    factors=defaultdict(int)
    for p in range(2,N):
        if p**2>N:
            break
        while N%p==0:
            factors[p]+=1
            N//=p
    if N!=1:
        factors[N]+=1
    return factors

A,B=map(float,input().split())
A=round(A*10000)
B=round(B*10000)
x,y=A,10000
if B<0:
    B=-B
    x,y=y,x
cnt=defaultdict(int)
for p,e in Factorize(x).items():
    cnt[p]+=e*B
for p,e in Factorize(y).items():
    cnt[p]-=e*B
ans="Yes"
for p,e in cnt.items():
    if e%10000 or e<0:
        ans="No"
print(ans)
0