結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー qibqib
提出日時 2023-05-29 21:02:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 337 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 86,412 KB
実行使用メモリ 77,380 KB
最終ジャッジ日時 2023-08-27 23:54:36
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,772 KB
testcase_01 WA -
testcase_02 AC 76 ms
76,160 KB
testcase_03 AC 77 ms
76,852 KB
testcase_04 WA -
testcase_05 AC 76 ms
76,500 KB
testcase_06 AC 77 ms
77,012 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 76 ms
75,848 KB
testcase_11 AC 76 ms
76,100 KB
testcase_12 AC 76 ms
75,768 KB
testcase_13 WA -
testcase_14 AC 78 ms
77,192 KB
testcase_15 WA -
testcase_16 AC 76 ms
75,676 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 76 ms
75,756 KB
testcase_20 AC 70 ms
70,900 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

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

fact = [1 for _ in range(n + 1)]
for x in range(2, n + 1):
  fact[x] = (fact[x - 1] * x) % MOD

dp = [0 for _ in range(n + 1)]
for x in range(2, n + 1):
  cur = x
  while cur % p == 0:
    dp[x] += 1
    cur //= p

ans = sum(dp) % MOD * pow(fact[n], fact[n], MOD - 1) % MOD
print(ans)
0