結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-05-28 15:41:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 77,152 KB
最終ジャッジ日時 2023-08-27 12:43:17
合計ジャッジ時間 3,835 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
77,016 KB
testcase_01 AC 96 ms
77,084 KB
testcase_02 AC 97 ms
77,080 KB
testcase_03 AC 96 ms
76,808 KB
testcase_04 AC 96 ms
76,912 KB
testcase_05 AC 96 ms
77,032 KB
testcase_06 AC 96 ms
76,860 KB
testcase_07 AC 96 ms
76,904 KB
testcase_08 AC 95 ms
76,928 KB
testcase_09 AC 96 ms
77,056 KB
testcase_10 AC 95 ms
76,900 KB
testcase_11 AC 96 ms
77,084 KB
testcase_12 AC 96 ms
77,012 KB
testcase_13 AC 97 ms
77,064 KB
testcase_14 AC 95 ms
76,952 KB
testcase_15 AC 95 ms
76,956 KB
testcase_16 AC 97 ms
77,152 KB
testcase_17 AC 95 ms
77,056 KB
testcase_18 AC 107 ms
76,856 KB
testcase_19 AC 94 ms
77,108 KB
testcase_20 AC 89 ms
71,788 KB
testcase_21 AC 88 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
import bisect
from collections import deque

N,P = map(int,stdin.readline().split())
mod = 10**9+7

x = 1
for i in range(1,N+1):
    x *= i
    x %= mod-1

y = 1
for i in range(1,N+1):
    y *= i
    y %= mod

z = 0
for i in range(1,40):

    if P**i > N:
        break
    z += N // (P**i)

ans = z * pow( y,x,mod ) % mod
print (ans)
0