結果

問題 No.2326 Factorial to the Power of Factorial to the...
コンテスト
ユーザー 094
提出日時 2023-05-28 16:50:01
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 210 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 314 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 82,560 KB
最終ジャッジ日時 2026-06-02 01:17:39
合計ジャッジ時間 3,390 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
MOD = 10**9 + 7

n, p = map(int, input().split())

nfact_cnt = 0
tmp = n
while tmp > 0:
	nfact_cnt += tmp // p
	tmp = tmp // p

fc = math.factorial(n)
print(nfact_cnt * pow(fc % MOD, fc, MOD) % MOD)
0