結果

問題 No.645 Count Permutation
コンテスト
ユーザー Pulmn
提出日時 2017-08-23 21:07:51
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 418 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 587 ms
コンパイル使用メモリ 78,192 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-04 17:44:27
合計ジャッジ時間 2,369 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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