結果

問題 No.2365 Present of good number
ユーザー titiatitia
提出日時 2023-06-30 22:20:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,595 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 85,484 KB
最終ジャッジ日時 2023-09-21 16:26:46
合計ジャッジ時間 7,228 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
85,204 KB
testcase_01 AC 128 ms
85,216 KB
testcase_02 AC 125 ms
85,212 KB
testcase_03 AC 125 ms
85,296 KB
testcase_04 AC 126 ms
85,244 KB
testcase_05 AC 127 ms
85,248 KB
testcase_06 AC 127 ms
85,200 KB
testcase_07 AC 126 ms
85,160 KB
testcase_08 AC 127 ms
85,204 KB
testcase_09 AC 127 ms
85,396 KB
testcase_10 AC 125 ms
85,200 KB
testcase_11 AC 125 ms
84,952 KB
testcase_12 AC 125 ms
85,484 KB
testcase_13 AC 125 ms
85,208 KB
testcase_14 AC 126 ms
85,104 KB
testcase_15 AC 130 ms
84,952 KB
testcase_16 AC 128 ms
85,204 KB
testcase_17 AC 126 ms
85,200 KB
testcase_18 AC 125 ms
85,048 KB
testcase_19 AC 126 ms
85,048 KB
testcase_20 AC 125 ms
85,200 KB
testcase_21 AC 125 ms
85,296 KB
testcase_22 AC 127 ms
85,096 KB
testcase_23 AC 126 ms
84,960 KB
testcase_24 AC 129 ms
85,284 KB
testcase_25 AC 128 ms
85,044 KB
testcase_26 AC 124 ms
85,368 KB
testcase_27 AC 125 ms
85,284 KB
testcase_28 AC 125 ms
84,952 KB
testcase_29 AC 128 ms
85,104 KB
testcase_30 AC 124 ms
85,236 KB
testcase_31 AC 126 ms
85,392 KB
testcase_32 AC 130 ms
84,956 KB
testcase_33 AC 124 ms
85,288 KB
testcase_34 AC 125 ms
84,952 KB
testcase_35 AC 124 ms
84,956 KB
testcase_36 AC 125 ms
85,224 KB
testcase_37 AC 126 ms
85,160 KB
testcase_38 AC 125 ms
85,224 KB
testcase_39 AC 124 ms
85,136 KB
testcase_40 AC 126 ms
85,388 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)%mod,D[d]*NOW[c],mod)%mod
                else:
                    ANS=ANS*pow(pow(3,pow(2,q,1000000006),mod)%mod,D[d]*NOW[c],mod)%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