結果

問題 No.2176 LRM Question 1
コンテスト
ユーザー D M
提出日時 2026-03-11 12:21:54
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 629 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,294 ms
コンパイル使用メモリ 377,128 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 12:22:07
合計ジャッジ時間 5,409 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using namespace atcoder;
using mint = dynamic_modint<0>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll L, R, M;
    cin >> L >> R >> M;

    mint::set_mod((int)M);

    ll N = min(R, M);  // n >= M では項は 0

    mint fact = 1;   // i!
    mint prod = 1;   // 1! * 2! * ... * i!
    mint ans = 0;

    for (ll i = 1; i <= N; i++) {
        fact *= i;     // fact = i!
        prod *= fact;  // prod = ∏_{k=1}^i k!
        if (i >= L) ans += prod;
    }

    cout << ans.val() << '\n';
    return 0;
}
0