結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,820 KB
testcase_01 AC 20 ms
8,848 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 20 ms
8,660 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 19 ms
8,640 KB
testcase_18 AC 20 ms
8,628 KB
testcase_19 WA -
testcase_20 AC 20 ms
8,784 KB
testcase_21 AC 20 ms
8,840 KB
testcase_22 WA -
testcase_23 AC 20 ms
8,704 KB
testcase_24 AC 20 ms
8,656 KB
testcase_25 WA -
testcase_26 AC 19 ms
8,632 KB
testcase_27 AC 19 ms
8,788 KB
testcase_28 AC 20 ms
8,656 KB
testcase_29 AC 19 ms
8,736 KB
testcase_30 AC 19 ms
8,652 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 19 ms
8,644 KB
testcase_37 AC 19 ms
8,636 KB
testcase_38 AC 20 ms
8,804 KB
testcase_39 AC 20 ms
8,740 KB
testcase_40 AC 20 ms
8,736 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(2*n)
c = {p:q for p,q 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
    if (k-i)%2==0 or set(c.keys())-{2,3}: continue
    r = pow(2,(k-i)//2,mod)
    exit(print(pow(2,c[2]*r,mod)*pow(3,c[3]*r,mod)%mod))
ans = 1
for p,q in c.items(): ans *= pow(p,q,mod)
print(ans%mod)
0