結果

問題 No.2176 LRM Question 1
ユーザー pengin_2000pengin_2000
提出日時 2023-05-08 01:02:59
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 1,168 ms
コンパイル使用メモリ 27,868 KB
実行使用メモリ 9,704 KB
最終ジャッジ日時 2023-08-16 10:41:34
合計ジャッジ時間 2,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
9,660 KB
testcase_01 AC 20 ms
9,684 KB
testcase_02 AC 40 ms
9,604 KB
testcase_03 AC 20 ms
9,640 KB
testcase_04 AC 19 ms
9,688 KB
testcase_05 AC 20 ms
9,604 KB
testcase_06 AC 20 ms
9,704 KB
testcase_07 AC 20 ms
9,620 KB
testcase_08 AC 20 ms
9,600 KB
testcase_09 AC 20 ms
9,700 KB
testcase_10 AC 37 ms
9,540 KB
testcase_11 AC 19 ms
9,628 KB
testcase_12 AC 20 ms
9,692 KB
testcase_13 AC 36 ms
9,548 KB
testcase_14 AC 41 ms
9,704 KB
testcase_15 AC 37 ms
9,640 KB
testcase_16 AC 33 ms
9,676 KB
testcase_17 AC 20 ms
9,556 KB
testcase_18 AC 34 ms
9,536 KB
testcase_19 AC 29 ms
9,676 KB
testcase_20 AC 23 ms
9,552 KB
testcase_21 AC 28 ms
9,588 KB
testcase_22 AC 20 ms
9,524 KB
testcase_23 AC 27 ms
9,688 KB
testcase_24 AC 27 ms
9,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
long long int fact[1000016];
int main()
{
	long long int l, r, m;
	scanf("%lld %lld %lld", &l, &r, &m);
	long long int ans = 0;
	long long int i;
	fact[0] = 1;
	for (i = 1; i < 1000006; i++)
		fact[i] = fact[i - 1] * i % m;
	long long int v = 1;
	for (i = 0; i < l && i < m; i++)
		v = v * fact[i] % m;
	for (i = l; i < m && i <= r; i++)
	{
		v = v * fact[i] % m;
		ans += v;
		ans %= m;
	}
	printf("%lld\n", ans);
	return 0;
}
0