結果

問題 No.645 Count Permutation
ユーザー chocoruskchocorusk
提出日時 2020-04-13 17:09:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 1,859 ms
コンパイル使用メモリ 127,376 KB
実行使用メモリ 50,556 KB
最終ジャッジ日時 2023-10-25 08:43:56
合計ジャッジ時間 3,976 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
50,556 KB
testcase_01 AC 16 ms
50,556 KB
testcase_02 AC 16 ms
50,556 KB
testcase_03 AC 16 ms
50,556 KB
testcase_04 AC 15 ms
50,556 KB
testcase_05 AC 16 ms
50,556 KB
testcase_06 AC 15 ms
50,556 KB
testcase_07 AC 16 ms
50,556 KB
testcase_08 AC 16 ms
50,556 KB
testcase_09 AC 16 ms
50,556 KB
testcase_10 AC 16 ms
50,556 KB
testcase_11 AC 21 ms
50,556 KB
testcase_12 AC 19 ms
50,556 KB
testcase_13 AC 21 ms
50,556 KB
testcase_14 AC 16 ms
50,556 KB
testcase_15 AC 43 ms
50,556 KB
testcase_16 AC 38 ms
50,556 KB
testcase_17 AC 72 ms
50,556 KB
testcase_18 AC 34 ms
50,556 KB
testcase_19 AC 75 ms
50,556 KB
testcase_20 AC 74 ms
50,556 KB
testcase_21 AC 61 ms
50,556 KB
testcase_22 AC 15 ms
50,556 KB
testcase_23 AC 16 ms
50,556 KB
testcase_24 AC 73 ms
50,556 KB
testcase_25 AC 46 ms
50,556 KB
testcase_26 AC 62 ms
50,556 KB
testcase_27 AC 41 ms
50,556 KB
testcase_28 AC 33 ms
50,556 KB
testcase_29 AC 59 ms
50,556 KB
testcase_30 AC 60 ms
50,556 KB
testcase_31 AC 64 ms
50,556 KB
testcase_32 AC 30 ms
50,556 KB
testcase_33 AC 30 ms
50,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n;
	ll l, r;
	cin>>n>>l>>r;
	ll dp[60][100010]={};
	dp[0][n]=1;
	for(int i=n-1; i>=1; i--){
		for(int j=0; j<60; j++){
			(dp[j][i]+=dp[j][i+1]*(n-1-i))%=MOD;
			if(j<59) (dp[j+1][i]+=dp[j][i+1])%=MOD;
		}
	}
	ll c0=n-1;
	for(int i=1; i<=n-1; i++) (c0*=i)%=MOD;
	ll ans=(l?0:c0);
	for(int i=1; i<60; i++){
		if((1ll<<i)<l || r<(1ll<<i)) continue;
		(ans+=dp[i][1])%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0