結果

問題 No.2326 Factorial to the Power of Factorial to the...
ユーザー redoCtAredoCtA
提出日時 2023-05-28 14:46:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 10,712 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-08-27 10:34:25
合計ジャッジ時間 1,531 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,852 KB
testcase_01 WA -
testcase_02 AC 19 ms
7,828 KB
testcase_03 AC 28 ms
7,912 KB
testcase_04 WA -
testcase_05 AC 23 ms
7,820 KB
testcase_06 AC 25 ms
7,908 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 17 ms
7,964 KB
testcase_11 AC 18 ms
7,920 KB
testcase_12 AC 16 ms
7,984 KB
testcase_13 WA -
testcase_14 AC 28 ms
7,908 KB
testcase_15 WA -
testcase_16 AC 15 ms
7,828 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 17 ms
7,924 KB
testcase_20 AC 15 ms
7,840 KB
testcase_21 AC 15 ms
7,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
    return sys.stdin.readline().rstrip()
def main():
    N, P = map(int, input().split())
    mod = 10**9+7
    p = 1
    ans = 0
    for i in range(1, N+1):
        p *= i
        p %= mod
        a = i
        while not a%P:
            a //= P
            ans += 1
    p = pow(p, p, mod)
    print(p*ans%mod)
if __name__ == "__main__":
    main()
0