結果

問題 No.2176 LRM Question 1
ユーザー coder_So_heycoder_So_hey
提出日時 2023-01-06 22:25:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 524 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-05-07 22:02:57
合計ジャッジ時間 5,300 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
16,256 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 WA -
testcase_05 AC 29 ms
10,752 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 29 ms
10,752 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def fac(n, m):
    if n > 1:
        n *= fac(n - 1, m)
        if n >= m:
            n %= m
        return n
    else:
        return 1

L, R, M = map(int, input().split())

if L >= M:
    print(0)
    exit()

facto = 1
index = 2
while facto != 0:
    facto *= fac(index, M)
    if facto >= M:
        facto %= M
    index += 1

ans = 0
for i in range(L, index):
    a = 1
    for j in range(1, i + 1):
        a *= fac(j, M)
        if a >= M:
            a %= M
    ans += a
    if ans >= M:
        ans %= M

print(ans)
0