結果

問題 No.1556 Power Equality
ユーザー moharan627moharan627
提出日時 2021-06-25 21:30:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,323 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 8,776 KB
最終ジャッジ日時 2023-09-07 15:51:32
合計ジャッジ時間 957 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,772 KB
testcase_01 AC 18 ms
8,572 KB
testcase_02 AC 18 ms
8,568 KB
testcase_03 AC 18 ms
8,700 KB
testcase_04 AC 19 ms
8,692 KB
testcase_05 AC 18 ms
8,680 KB
testcase_06 AC 19 ms
8,768 KB
testcase_07 AC 19 ms
8,656 KB
testcase_08 AC 18 ms
8,684 KB
testcase_09 AC 18 ms
8,640 KB
testcase_10 AC 18 ms
8,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
#10**20に変えるのもあり
MOD = 10**9 + 7
MOD2 = 998244353
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    A,B = MI()
    import collections
    APri = prime_factorize(A)
    BPri = prime_factorize(B)
    from collections import defaultdict
    ANum = defaultdict(lambda: 0)
    for a in APri:
        ANum[a]+=1
    BNum = defaultdict(lambda: 0)
    for b in BPri:
        BNum[b]+=1
    #print(ANum)
    #print(BNum)
    flag = True
    for a in ANum.keys():
        if(ANum[a]*B != BNum[a]*A):
            flag = False
    for b in BNum.keys():
        if (ANum[b] * B != BNum[b] * A):
            flag = False
    if(flag):
        print("Yes")
    else:
        print("No")
    return
solve()
0