結果

問題 No.645 Count Permutation
ユーザー 👑 kmjpkmjp
提出日時 2018-02-02 23:29:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,097 bytes
コンパイル時間 1,193 ms
コンパイル使用メモリ 145,452 KB
実行使用メモリ 4,440 KB
最終ジャッジ日時 2023-08-30 02:30:37
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 3 ms
4,440 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 12 ms
4,380 KB
testcase_13 AC 17 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 69 ms
4,376 KB
testcase_16 AC 57 ms
4,380 KB
testcase_17 AC 140 ms
4,376 KB
testcase_18 AC 49 ms
4,380 KB
testcase_19 AC 145 ms
4,380 KB
testcase_20 AC 145 ms
4,376 KB
testcase_21 AC 114 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 145 ms
4,376 KB
testcase_25 AC 79 ms
4,380 KB
testcase_26 AC 122 ms
4,376 KB
testcase_27 AC 68 ms
4,376 KB
testcase_28 AC 48 ms
4,376 KB
testcase_29 AC 112 ms
4,380 KB
testcase_30 AC 113 ms
4,380 KB
testcase_31 AC 122 ms
4,376 KB
testcase_32 AC 39 ms
4,376 KB
testcase_33 AC 39 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,L,R;
ll mo=1000000007;
ll fact[101010];
ll dp[70];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	fact[0]=1;
	for(i=1;i<=100100;i++) fact[i]=fact[i-1]*i%mo;
	
	cin>>N>>L>>R;
	dp[1]=1;
	for(i=2;i<=N-1;i++) {
		for(j=65;j>=1;j--) {
			(dp[j+1]+=dp[j])%=mo;
			(dp[j]*=i-1)%=mo;
		}
	}
	ll ret=0;
	for(i=1;i<=61;i++) if(L<=(1LL<<i) && (1LL<<i)<=R) ret+=dp[i];
	if(L==0) ret+=mo+fact[N]-fact[N-1];
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0