結果

問題 No.645 Count Permutation
ユーザー square1001square1001
提出日時 2018-02-02 22:42:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 31,948 KB
実行使用メモリ 27,988 KB
最終ジャッジ日時 2023-08-30 02:20:36
合計ジャッジ時間 2,458 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 9 ms
7,076 KB
testcase_12 AC 6 ms
4,476 KB
testcase_13 AC 9 ms
7,040 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 34 ms
15,280 KB
testcase_16 AC 28 ms
13,184 KB
testcase_17 AC 68 ms
27,624 KB
testcase_18 AC 24 ms
11,176 KB
testcase_19 AC 70 ms
27,944 KB
testcase_20 AC 70 ms
27,984 KB
testcase_21 AC 56 ms
23,508 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 71 ms
27,988 KB
testcase_25 AC 38 ms
17,336 KB
testcase_26 AC 59 ms
25,468 KB
testcase_27 AC 33 ms
15,232 KB
testcase_28 AC 23 ms
11,200 KB
testcase_29 AC 54 ms
23,364 KB
testcase_30 AC 55 ms
23,412 KB
testcase_31 AC 60 ms
25,584 KB
testcase_32 AC 19 ms
11,188 KB
testcase_33 AC 20 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
int N, dp[100009][64], ret, fact = 1, mod = 1000000007; long long L, R;
int main() {
	scanf("%d%lld%lld", &N, &L, &R); dp[0][0] = 1;
	for (int i = 1; i < N; i++) {
		fact = 1LL * fact * i % mod;
		for (int j = 0; j < 60; j++) dp[i][j] = (1LL * dp[i - 1][j] * (i - 1) + (j >= 1 ? dp[i - 1][j - 1] : 0)) % mod;
	}
	for (int i = 0; i < 60; i++) if (L <= 1LL << i && 1LL << i <= R) ret = (ret + dp[N - 1][i]) % mod;
	if (L == 0) ret = (ret + 1LL * fact * (N - 1)) % mod;
	printf("%d\n", ret);
	return 0;
}
0