結果

問題 No.1556 Power Equality
ユーザー ygd.ygd.
提出日時 2021-06-29 19:41:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 75,824 KB
最終ジャッジ日時 2023-09-08 04:49:36
合計ジャッジ時間 2,168 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,540 KB
testcase_01 AC 70 ms
71,512 KB
testcase_02 AC 70 ms
71,540 KB
testcase_03 AC 72 ms
75,516 KB
testcase_04 AC 69 ms
71,532 KB
testcase_05 AC 73 ms
71,456 KB
testcase_06 AC 76 ms
75,496 KB
testcase_07 AC 72 ms
75,596 KB
testcase_08 AC 68 ms
71,360 KB
testcase_09 AC 69 ms
71,684 KB
testcase_10 AC 69 ms
75,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1: #最後に残ったもの(もしくは素数)の場合はここ
        arr.append([temp, 1])
 
    if arr==[]: #1の場合はここ
        arr.append([n, 1])
 
    return arr

def main():
    A,B = map(int,input().split())
    pa = factorization(A)
    for i in range(len(pa)):
        pa[i][1] *= B
    pb = factorization(B)
    for i in range(len(pb)):
        pb[i][1] *= A
    #print(pa,pb)
    if pa == pb:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()
0