結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,904 KB
testcase_01 AC 19 ms
8,780 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 19 ms
8,808 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 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 20 ms
8,728 KB
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 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 18 ms
8,796 KB
testcase_37 AC 19 ms
8,808 KB
testcase_38 AC 18 ms
8,804 KB
testcase_39 AC 18 ms
8,780 KB
testcase_40 AC 19 ms
8,720 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 = {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[2]*pow(2,(k-i)//2,mod),mod))
    exit(print(ans%mod))
ans = 1
for p,q in c.items(): ans *= pow(p,q,mod)
print(ans%mod)
0