結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー ShirotsumeShirotsume
提出日時 2021-10-29 21:33:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,510 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 61,568 KB
最終ジャッジ日時 2024-04-16 14:14:45
合計ジャッジ時間 4,333 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
55,680 KB
testcase_01 AC 52 ms
55,552 KB
testcase_02 AC 51 ms
55,680 KB
testcase_03 AC 57 ms
60,800 KB
testcase_04 AC 56 ms
60,928 KB
testcase_05 AC 59 ms
61,568 KB
testcase_06 AC 57 ms
61,056 KB
testcase_07 AC 57 ms
60,672 KB
testcase_08 AC 57 ms
61,184 KB
testcase_09 AC 57 ms
60,672 KB
testcase_10 AC 56 ms
61,056 KB
testcase_11 AC 56 ms
60,672 KB
testcase_12 AC 57 ms
61,184 KB
testcase_13 AC 58 ms
60,672 KB
testcase_14 AC 56 ms
61,184 KB
testcase_15 AC 57 ms
60,800 KB
testcase_16 AC 56 ms
61,056 KB
testcase_17 AC 56 ms
60,672 KB
testcase_18 AC 55 ms
60,800 KB
testcase_19 AC 56 ms
61,056 KB
testcase_20 AC 58 ms
61,312 KB
testcase_21 AC 56 ms
60,928 KB
testcase_22 AC 57 ms
61,184 KB
testcase_23 AC 57 ms
61,056 KB
testcase_24 AC 57 ms
61,184 KB
testcase_25 AC 58 ms
61,184 KB
testcase_26 AC 56 ms
60,672 KB
testcase_27 AC 60 ms
60,800 KB
testcase_28 AC 59 ms
60,928 KB
testcase_29 AC 57 ms
61,312 KB
testcase_30 AC 57 ms
60,800 KB
testcase_31 AC 58 ms
61,184 KB
testcase_32 AC 57 ms
61,312 KB
testcase_33 AC 51 ms
55,808 KB
testcase_34 AC 50 ms
55,424 KB
testcase_35 AC 52 ms
55,424 KB
testcase_36 AC 58 ms
60,800 KB
testcase_37 AC 52 ms
55,680 KB
testcase_38 AC 52 ms
55,424 KB
testcase_39 AC 51 ms
55,680 KB
testcase_40 AC 51 ms
55,552 KB
testcase_41 AC 51 ms
55,680 KB
testcase_42 AC 52 ms
55,552 KB
testcase_43 AC 51 ms
55,552 KB
testcase_44 AC 51 ms
55,296 KB
testcase_45 AC 52 ms
55,552 KB
testcase_46 AC 52 ms
55,552 KB
testcase_47 AC 52 ms
55,552 KB
testcase_48 AC 51 ms
55,424 KB
testcase_49 AC 52 ms
55,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import random
from collections import defaultdict
def is_prime(n):
    if n==2:
        return True
    if n==1 or n&1==0:
        return False
    d=(n-1)>>1
    while d&1==0:
        d>>=1

    for k in range(100):
        a=random.randint(1,n-1)
        t=d
        y=pow(a, t, n)
        while t!=n-1 and y!=1 and y!=n-1:
            y=(y*y)%n
            t<<=1
        if y!=n-1 and t&1==0:
            return False
    return True

def prime_fact(N):
    res=defaultdict(int)
    if N==1:
        return res
    p=2
    while(p<=10**4 and N>1):
        if N%p==0:
            while(N%p==0):
                res[p]+=1
                N//=p
        p+=1
    while(N>1):
        if is_prime(N):
            res[N]+=1
            break
        x=random.randrange(N)
        y=(x*x+1)%N
        i=1
        while(True):
            d=gcd(abs(x-y),N)
            if d==1:
                i+=1
            elif d==N:
                res[N]+=1
                return res
            else:
                res[d]+=1
                N//=d
                break
            x=(x*x+1)%N
            y=(y*y+1)%N
            y=(y*y+1)%N
    return res

x, a, y, b = map(int,input().split())
if y == 1:
    print('Yes')
    exit()
dx = prime_fact(x)
dy = prime_fact(y)

for i in dx.keys():
    dx[i] *= a
for i in dy.keys():
    dy[i] *= b
ans = 'Yes'

for i in dy.keys():
    if not (i in dx):
        ans = 'No'
    if i in dx.keys():
        if dy[i] > dx[i]:
            ans = 'No'
print(ans)

0