結果

問題 No.2176 LRM Question 1
ユーザー ぷらぷら
提出日時 2023-01-06 21:26:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 2,776 ms
コンパイル使用メモリ 198,596 KB
実行使用メモリ 11,232 KB
最終ジャッジ日時 2023-08-20 14:27:35
合計ジャッジ時間 3,663 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 42 ms
11,216 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 26 ms
11,196 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 27 ms
11,200 KB
testcase_09 AC 26 ms
11,028 KB
testcase_10 AC 35 ms
10,108 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 26 ms
11,180 KB
testcase_14 AC 43 ms
11,232 KB
testcase_15 AC 34 ms
9,548 KB
testcase_16 AC 28 ms
9,660 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 24 ms
10,604 KB
testcase_19 AC 17 ms
9,488 KB
testcase_20 AC 8 ms
5,056 KB
testcase_21 AC 18 ms
7,504 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 16 ms
7,440 KB
testcase_24 AC 12 ms
7,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long f[1001001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long L,R;
    int M;
    cin >> L >> R >> M;
    long long tmp = 1;
    f[0] = 1;
    for(int i = 1; i <= M; i++) {
        tmp = tmp*i%M;
        f[i] = (f[i-1]*tmp)%M;
    }
    long long ans = 0;
    for(long long i = L; i <= min(R,(long long)M); i++) {
        ans += f[i];
        ans %= M;
    }
    cout << ans << endl;
}
0