結果
問題 | No.1556 Power Equality |
ユーザー |
|
提出日時 | 2021-06-25 21:30:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,323 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-06-25 09:45:43 |
合計ジャッジ時間 | 985 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 |
ソースコード
import sys#sys.setrecursionlimit(10 ** 6)INF = float('inf')#10**20に変えるのもありMOD = 10**9 + 7MOD2 = 998244353def 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 //= 2f = 3while f * f <= n:if n % f == 0:a.append(f)n //= felse:f += 2if n != 1:a.append(n)return aA,B = MI()import collectionsAPri = prime_factorize(A)BPri = prime_factorize(B)from collections import defaultdictANum = defaultdict(lambda: 0)for a in APri:ANum[a]+=1BNum = defaultdict(lambda: 0)for b in BPri:BNum[b]+=1#print(ANum)#print(BNum)flag = Truefor a in ANum.keys():if(ANum[a]*B != BNum[a]*A):flag = Falsefor b in BNum.keys():if (ANum[b] * B != BNum[b] * A):flag = Falseif(flag):print("Yes")else:print("No")returnsolve()