結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー qibqib
提出日時 2023-05-29 21:00:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 333 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 77,708 KB
最終ジャッジ日時 2023-08-27 23:54:30
合計ジャッジ時間 3,511 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,948 KB
testcase_01 WA -
testcase_02 AC 76 ms
76,012 KB
testcase_03 AC 78 ms
77,136 KB
testcase_04 WA -
testcase_05 AC 76 ms
76,320 KB
testcase_06 AC 78 ms
76,668 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 77 ms
75,620 KB
testcase_11 AC 77 ms
75,916 KB
testcase_12 AC 76 ms
75,840 KB
testcase_13 WA -
testcase_14 AC 79 ms
77,008 KB
testcase_15 WA -
testcase_16 AC 77 ms
75,756 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 78 ms
75,780 KB
testcase_20 AC 69 ms
71,164 KB
testcase_21 AC 70 ms
71,236 KB
権限があれば一括ダウンロードができます

ソースコード

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) % MOD
print(ans)
0