結果
| 問題 |
No.2176 LRM Question 1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-06 21:56:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 581 bytes |
| コンパイル時間 | 2,103 ms |
| コンパイル使用メモリ | 192,524 KB |
| 最終ジャッジ日時 | 2025-02-09 23:53:45 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void fast_io() {
cin.tie(nullptr)->sync_with_stdio(false);
}
const int MAX = 1e6;
ll fac[MAX + 1], facp[MAX + 1];
void solve() {
ll L, R, M;
cin >> L >> R >> M;
fac[0] = 1;
for (int i = 1; i <= M; i++) fac[i] = fac[i - 1] * i % M;
facp[0] = 1;
for (int i = 1; i <= M; i++) facp[i] = facp[i - 1] * fac[i] % M;
ll ans = 0;
for (ll i = L; i <= min(M, R); i++) ans = (ans + facp[i]) % M;
cout << ans << '\n';
}
int main() {
fast_io();
int t = 1;
// cin >> t;
while (t--) solve();
}