結果
| 問題 |
No.2176 LRM Question 1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-09 12:12:23 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 717 bytes |
| コンパイル時間 | 6,638 ms |
| コンパイル使用メモリ | 309,148 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2024-12-29 22:34:51 |
| 合計ジャッジ時間 | 7,590 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
vector<mint> DP(1000010);
mint Solve(ll N, ll M)
{
N = min(N,M-1);
return DP[N];
}
int main()
{
ll L,R,M; cin >> L >> R >> M;
modint::set_mod(M);
mint P = 1, Sum = 1, Ans = 1;
DP[1] = 1;
for(int i = 2; i <= 1000000; i++)
{
P *= i;
Sum *= P;
Ans += Sum;
DP[i] = Ans;
}
cout << (Solve(R,M)-Solve(L-1,M)).val() << endl;
return 0;
}