結果
問題 | No.2176 LRM Question 1 |
ユーザー |
![]() |
提出日時 | 2023-01-06 22:45:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 500 bytes |
コンパイル時間 | 3,353 ms |
コンパイル使用メモリ | 246,092 KB |
実行使用メモリ | 11,312 KB |
最終ジャッジ日時 | 2024-11-30 19:13:26 |
合計ジャッジ時間 | 4,331 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 14 WA * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;ll m;vector<ll> memo(1000007,-1);ll mfac(ll x){if(memo[x]!=-1)return memo[x];if(x==0)return 1;return memo[x]=x*mfac(x-1)%m;}int main(){ll l,r;cin>>l>>r>>m;if(l>=m){cout<<0<<endl;return 0;}ll fac_l=mfac(l);ll ans=fac_l;for(ll i=l+1;i<=min(m-1,r);i++){fac_l=fac_l*mfac(i)%m;ans+=fac_l;ans%=m;}cout<<ans<<endl;return 0;}