結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー sepa38
提出日時 2023-05-05 21:08:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2024-11-23 05:38:48
合計ジャッジ時間 2,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

# fpfpf

n, p = map(int, input().split())
mod = 10 ** 9 + 7
m = 0
for i in range(1, 20):
  if n // pow(p, i) == 0:
    break
  m += n // pow(p, i)
fac0 = 1
fac1 = 1
for i in range(n):
  fac0 *= i + 1
  fac0 %= mod
  fac1 *= i + 1
  fac1 %= mod - 1
ans = m * pow(fac0, fac1, mod) % mod
print(ans)
0