結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,628 KB
testcase_01 AC 82 ms
76,660 KB
testcase_02 AC 76 ms
76,168 KB
testcase_03 AC 76 ms
76,488 KB
testcase_04 AC 77 ms
76,292 KB
testcase_05 AC 76 ms
76,288 KB
testcase_06 AC 78 ms
76,320 KB
testcase_07 AC 79 ms
76,708 KB
testcase_08 AC 79 ms
76,568 KB
testcase_09 AC 78 ms
76,396 KB
testcase_10 AC 77 ms
75,488 KB
testcase_11 AC 76 ms
75,652 KB
testcase_12 AC 75 ms
75,776 KB
testcase_13 AC 77 ms
76,248 KB
testcase_14 AC 78 ms
76,536 KB
testcase_15 AC 76 ms
75,592 KB
testcase_16 AC 76 ms
75,664 KB
testcase_17 AC 78 ms
76,228 KB
testcase_18 AC 76 ms
75,844 KB
testcase_19 AC 77 ms
75,708 KB
testcase_20 AC 70 ms
71,148 KB
testcase_21 AC 72 ms
71,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

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

power = 1
base = 1
for x in range(2, n + 1):
  power = (power * x) % (MOD - 1)
  base = (base * 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(base, power, MOD) % MOD
print(ans)
0