結果

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

ソースコード

diff #

import math
import sys

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

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