結果
問題 |
No.2176 LRM Question 1
|
ユーザー |
|
提出日時 | 2023-01-07 05:34:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 1,814 ms |
コンパイル使用メモリ | 167,652 KB |
実行使用メモリ | 11,412 KB |
最終ジャッジ日時 | 2024-12-14 04:47:01 |
合計ジャッジ時間 | 2,776 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<int(n);i++) typedef long long ll; typedef pair<int,int> P; ll p[1000010]; int main(void){ ll i; cin.tie(0); ios_base::sync_with_stdio(false); ll L,R,M; cin >> L >> R >> M; ll a=1; for(i=1;i<=M-1;i++){ a*=i; a%=M; p[i]=a; } for(i=2;i<=M-1;i++){ p[i]*=p[i-1]; p[i]%=M; } ll ans=0; if(L<M && M<=R){ for(i=L;i<=M-1;i++){ ans+=p[i]; ans%=M; } } else if(R<M){ for(i=L;i<=R;i++){ ans+=p[i]; ans%=M; } } cout << ans << endl; return 0; }