結果
問題 | No.2176 LRM Question 1 |
ユーザー |
![]() |
提出日時 | 2023-01-06 21:33:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 1,808 ms |
コンパイル使用メモリ | 194,056 KB |
最終ジャッジ日時 | 2025-02-09 23:42:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include<bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);ll l,r,m;cin>>l>>r>>m;if(m<=l || m==1){cout<<0<<endl;return 0;}vector<ll> ka(1000100);ka[0]=1,ka[1]=1;for(ll i=2;i<1000100;i++) ka[i]=ka[i-1]*i%m;vector<ll> A(1000100);A[1]=ka[1];for(ll i=2;i<1000100;i++) A[i]=A[i-1]*ka[i]%m;vector<ll> S(1000100);S[0]=0;for(ll i=1;i<1000100;i++) S[i]=(S[i-1]+A[i])%m;cout<<(S[min(m-1,r)]-S[l-1]+m)%m<<endl;return 0;}