結果

問題 No.2176 LRM Question 1
ユーザー Mat_h
提出日時 2023-01-06 22:46:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 335 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 22,800 KB
最終ジャッジ日時 2024-11-30 19:16:19
合計ジャッジ時間 26,278 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

l,r,m=map(int,input().split())
ans=1
for i in range(1,l+1):
    ans*=math.factorial(i)%m
    if ans==0:
        print(0)
        sys.exit()

temp=ans        
for i in range(l+1,r+1):
    temp=temp*math.factorial(i)
    ans+=temp%m
    ans=ans%m
    if temp%m==0:
        print(ans)
        sys.exit()
print(ans)
0