結果

問題 No.2365 Present of good number
ユーザー titiatitia
提出日時 2023-06-30 22:14:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,600 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 85,480 KB
最終ジャッジ日時 2023-09-21 16:18:38
合計ジャッジ時間 8,655 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
85,116 KB
testcase_01 AC 160 ms
85,208 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 157 ms
85,448 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 160 ms
85,252 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 157 ms
85,268 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 156 ms
85,128 KB
testcase_37 AC 155 ms
85,252 KB
testcase_38 AC 158 ms
85,244 KB
testcase_39 AC 156 ms
85,120 KB
testcase_40 AC 158 ms
85,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import Counter

N,K=map(int,input().split())

mod=10**9+7

# エラトステネスの篩を用いた素因数分解・約数列挙
MAX=10**6+10 # 使いたい最大値を指定

# Sieve[i]で、iの最も小さい約数を返す。
Sieve=[i for i in range(MAX)]

for i in range(2,MAX):
    if Sieve[i]!=i:
        continue
    
    for j in range(i,MAX,i):
        if Sieve[j]==j:
            Sieve[j]=i

# 素因数分解
def fact(x):
    if x==1:
        return {1:1}
    D=dict()
    while x!=1:
        k=Sieve[x]
        if k in D:
            D[k]+=1
        else:
            D[k]=1
        x//=k
    return D

# 約数列挙
def faclist(x):
    LIST=[1]
    while x!=1:
        k=Sieve[x]
        count=0
        while x%k==0:
            count+=1
            x//=k

        LIST2=[]
        for l in LIST:
            for i in range(1,count+1):
                LIST2.append(l*k**i)
        LIST+=LIST2

    return LIST

ANS=1

NOW=fact(N)
while K and len(NOW)!=0:
    NNOW=Counter()

    for c in NOW:
        a=c+1
        D=fact(a)

        for d in D:
            if d==2:
                q=(K-1)//2
                r=(K-1)%2

                if r==0:
                    ANS=ANS*pow(pow(2,pow(2,q,1000000006),mod)%1000000006,D[d]*NOW[c],mod)
                else:
                    ANS=ANS*pow(pow(3,pow(2,q,1000000006),mod)%1000000006,D[d]*NOW[c],mod)
            else:
                NNOW[d]+=D[d]*NOW[c]
                NNOW[d]%=1000000006
    NOW=NNOW
    K-=1
    
for c in NOW:
    ANS=ANS*pow(c,NOW[c],mod)%mod

print(ANS)
0