結果

問題 No.2176 LRM Question 1
ユーザー 👑 Kazun
提出日時 2023-01-06 21:26:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 73,728 KB
最終ジャッジ日時 2024-11-30 17:12:29
合計ジャッジ時間 2,422 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    if L>M:
        L=M
    if R>M:
        R=M

    fact=[1]*(M+1)
    for i in range(1,M+1):
        fact[i]=i*fact[i-1]%M

    prod=[1]*(M+1)
    for i in range(1,M+1):
        prod[i]=fact[i]*prod[i-1]%M

    X=0
    for i in range(L,R+1):
        X+=prod[i]
    return X%M

#==================================================
print(solve())
0