結果

問題 No.2365 Present of good number
ユーザー ニックネームニックネーム
提出日時 2023-06-30 22:34:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,430 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 8,928 KB
最終ジャッジ日時 2023-09-21 16:43:51
合計ジャッジ時間 4,268 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,848 KB
testcase_01 AC 19 ms
8,856 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 20 ms
8,696 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

class PrimeNumbers:
    def __init__(self,nmax):
        from math import isqrt
        rootnmax = isqrt(nmax)
        self.prime_judgement = [True]*(rootnmax+1)
        self.prime_judgement[0] = self.prime_judgement[1] = False
        for i in range(2,rootnmax+1):
            if self.prime_judgement[i]:
                for j in range(2,rootnmax//i+1):
                    self.prime_judgement[i*j] = False
        self.prime_list = []
        for i,flag in enumerate(self.prime_judgement):
            if flag: self.prime_list.append(i)
    def prime_factorization(self,n):
        return_list = []
        for i in self.prime_list:
            if n==1 or i*i>n: break
            if n%i==0:
                return_list.append([i,0])
                while n%i==0: return_list[-1][1] += 1; n //= i
        if n!=1: return_list.append([n,1])
        return return_list
from collections import defaultdict
n,k = map(int,input().split())
mod = 10**9+7
pn = PrimeNumbers(2*n)
c = {k:v for k,v in pn.prime_factorization(n)}
for i in range(k):
    d = defaultdict(int)
    for k,v in c.items():
        for x,y in pn.prime_factorization(k+1): d[x] += y*v
    c = d; ans = 1
    if (k-i)%2==0 or set(c.keys())-{2,3}: continue
    if 2 in c: ans *= (pow(2,c[2]*pow(2,(k-i)//2,mod),mod))
    if 3 in c: ans *= (pow(3,c[2]*pow(2,(k-i)//2,mod),mod))
    exit(print(ans%mod))
ans = 1
for k,v in c.items(): ans *= pow(k,v,mod)
print(ans%mod)
0