結果

問題 No.2365 Present of good number
ユーザー ニックネームニックネーム
提出日時 2023-06-30 22:52:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,424 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 8,924 KB
最終ジャッジ日時 2023-09-21 17:05:54
合計ジャッジ時間 2,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,632 KB
testcase_01 AC 20 ms
8,788 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 18 ms
8,736 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 WA -
testcase_17 AC 18 ms
8,660 KB
testcase_18 AC 19 ms
8,720 KB
testcase_19 WA -
testcase_20 AC 19 ms
8,692 KB
testcase_21 AC 18 ms
8,700 KB
testcase_22 WA -
testcase_23 AC 18 ms
8,728 KB
testcase_24 AC 19 ms
8,628 KB
testcase_25 WA -
testcase_26 AC 19 ms
8,724 KB
testcase_27 AC 18 ms
8,652 KB
testcase_28 AC 18 ms
8,796 KB
testcase_29 AC 18 ms
8,844 KB
testcase_30 AC 18 ms
8,780 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 18 ms
8,728 KB
testcase_37 AC 18 ms
8,776 KB
testcase_38 AC 18 ms
8,700 KB
testcase_39 AC 18 ms
8,848 KB
testcase_40 AC 18 ms
8,844 KB
権限があれば一括ダウンロードができます

ソースコード

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(10**6)
c = {k:v for k,v in pn.prime_factorization(n)}
for i in range(k):
    d = defaultdict(int)
    for p,q in c.items():
        for x,y in pn.prime_factorization(p+1): d[x] += y*q
    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[3]*pow(2,(k-i)//2,mod),mod))
    exit(print(ans%mod))
for p,q in c.items(): ans *= pow(p,q,mod)
print(ans%mod)
0