結果
| 問題 | No.2176 LRM Question 1 | 
| コンテスト | |
| ユーザー |  planes | 
| 提出日時 | 2023-01-07 15:14:00 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 40 ms / 2,000 ms | 
| コード長 | 552 bytes | 
| コンパイル時間 | 1,506 ms | 
| コンパイル使用メモリ | 168,076 KB | 
| 実行使用メモリ | 10,992 KB | 
| 最終ジャッジ日時 | 2024-12-14 15:03:18 | 
| 合計ジャッジ時間 | 2,664 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
int main() {
  ll L,R,M;cin>>L>>R>>M;
if(M<=L) {
    cout<<0<<endl;
    return 0;
  }
  vector<ll> t(M+1,1);
  for(ll i=1;i<=M;i++) {
    t[i]=t[i-1]*i;
    t[i]%=M;
  }
  ll s=0;
  ll now=1;
  for(ll i=1;i<=L;i++) {
    now*=t[i];
    now%=M;
  }
  s+=now;
  s%=M;
  for(ll i=L+1;i<=min(R,M-1);i++) {
now*=t[i];
now%=M;
s+=now;
  s%=M;
  }
  cout<<s<<endl;
}
            
            
            
        