結果

問題 No.645 Count Permutation
ユーザー PulmnPulmn
提出日時 2017-08-23 21:07:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 62,396 KB
実行使用メモリ 5,704 KB
最終ジャッジ日時 2023-08-30 01:51:58
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 22 ms
4,384 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 AC 41 ms
5,704 KB
testcase_18 AC 14 ms
4,376 KB
testcase_19 AC 43 ms
5,552 KB
testcase_20 AC 18 ms
5,424 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 50 ms
5,352 KB
testcase_25 AC 25 ms
4,380 KB
testcase_26 AC 29 ms
4,908 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 13 ms
4,380 KB
testcase_29 AC 23 ms
4,976 KB
testcase_30 AC 29 ms
4,968 KB
testcase_31 AC 28 ms
4,900 KB
testcase_32 AC 9 ms
4,376 KB
testcase_33 AC 9 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;

const ll mod=1e9+7;

ll n,l,r;

int main(){
	cin>>n>>l>>r;
	vl dp(n);
	dp[0]=1;
	ll x=2,res=0;
	if(!l){
		res=n-1;
		for(int i=1;i<n;i++) (res*=i)%=mod;
	}
	while(x<=r){
		vl DP(n+1);
		for(int i=1;i<n;i++) DP[i]=((n-i)*DP[i-1]+dp[i-1])%mod;
		dp=DP;
		if(l<=x) (res+=dp[n-1])%=mod;
		x*=2;
	}
	cout<<res<<endl;
}
0