結果

問題 No.2176 LRM Question 1
ユーザー MazesobaMazesoba
提出日時 2023-01-06 21:45:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 6,405 ms
コンパイル使用メモリ 259,188 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-20 14:50:11
合計ジャッジ時間 5,958 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 18 ms
4,384 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 1 ms
4,388 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;

// #define DISABLE_PRINT

#if defined(ENABLE_PRINT) && !defined(DISABLE_PRINT)

#define P(...) fprintf(stderr, __VA_ARGS__)
#define LP fprintf(stderr, "L: %d\n", __LINE__)

#else

#define P(...) ((void)0)
#define LP ((void)0)

#endif

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(), x.end()

using ll = long long;
using ull = unsigned long long;

const int INF = 1100100100;
const ll INFLL = 1100100100100100100;

using mint = atcoder::dynamic_modint<0>;

int main() {
    ll L, R, M;
    cin >> L >> R >> M;

    mint::set_mod(M);

    auto ans = [&]() -> mint {
        mint f = 1;
        mint x = 1;
        mint ans = 0;
        for (ll i = 0; i < L; ++i) {
            f *= (i + 1);
            x *= f;
            if (x == 0) break;
        }
        ans += x;
        LP;
        if (x.val() == 0) return ans;
        LP;
        for (ll i = 0; i < (R - L); ++i) {
            f *= (L + 1 + i);
            x *= f;
            ans += x;
            if (x.val() == 0) break;
        }
        LP;
        return ans;
    }();

    cout << ans.val() << endl;

    return 0;
}
0