結果
| 問題 | No.2176 LRM Question 1 | 
| コンテスト | |
| ユーザー |  とりゐ | 
| 提出日時 | 2023-01-06 21:24:22 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 56 ms / 2,000 ms | 
| コード長 | 335 bytes | 
| コンパイル時間 | 182 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 58,112 KB | 
| 最終ジャッジ日時 | 2024-11-30 17:10:13 | 
| 合計ジャッジ時間 | 2,185 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
from sys import stdin
input=lambda :stdin.readline()[:-1]
L,R,M=map(int,input().split())
if M<=L:
  print(0)
  exit()
res=1
res2=1
for i in range(1,L):
  res2*=i
  res2%=M
  res*=res2
  res%=M
ans=0
for i in range(L,R+1):
  res2*=i
  res2%=M
  res*=res2
  res%=M
  if res%M==0:
    print(ans)
    exit()
  ans+=res
  ans%=M
print(ans)
            
            
            
        