結果

問題 No.916 Encounter On A Tree
ユーザー leaf_1415leaf_1415
提出日時 2019-10-25 22:01:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,354 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 53,520 KB
実行使用メモリ 34,824 KB
最終ジャッジ日時 2023-10-11 04:18:06
合計ジャッジ時間 4,965 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
34,728 KB
testcase_01 AC 33 ms
34,760 KB
testcase_02 AC 33 ms
34,576 KB
testcase_03 AC 33 ms
34,620 KB
testcase_04 AC 33 ms
34,576 KB
testcase_05 WA -
testcase_06 AC 33 ms
34,580 KB
testcase_07 AC 32 ms
34,588 KB
testcase_08 AC 33 ms
34,572 KB
testcase_09 AC 33 ms
34,628 KB
testcase_10 AC 33 ms
34,576 KB
testcase_11 AC 33 ms
34,624 KB
testcase_12 AC 33 ms
34,664 KB
testcase_13 AC 33 ms
34,544 KB
testcase_14 WA -
testcase_15 AC 32 ms
34,696 KB
testcase_16 AC 33 ms
34,584 KB
testcase_17 WA -
testcase_18 AC 32 ms
34,620 KB
testcase_19 AC 32 ms
34,824 KB
testcase_20 AC 33 ms
34,700 KB
testcase_21 WA -
testcase_22 AC 33 ms
34,588 KB
testcase_23 WA -
testcase_24 AC 33 ms
34,572 KB
testcase_25 AC 33 ms
34,636 KB
testcase_26 AC 34 ms
34,564 KB
testcase_27 AC 33 ms
34,564 KB
testcase_28 AC 33 ms
34,704 KB
testcase_29 WA -
testcase_30 AC 33 ms
34,824 KB
testcase_31 WA -
testcase_32 AC 33 ms
34,576 KB
testcase_33 WA -
testcase_34 AC 33 ms
34,728 KB
testcase_35 AC 32 ms
34,640 KB
testcase_36 AC 33 ms
34,792 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 33 ms
34,824 KB
testcase_41 AC 32 ms
34,572 KB
testcase_42 AC 32 ms
34,700 KB
testcase_43 AC 32 ms
34,572 KB
testcase_44 AC 32 ms
34,588 KB
testcase_45 AC 32 ms
34,568 KB
testcase_46 AC 33 ms
34,640 KB
testcase_47 AC 33 ms
34,564 KB
testcase_48 AC 32 ms
34,620 KB
testcase_49 AC 32 ms
34,592 KB
testcase_50 AC 33 ms
34,560 KB
testcase_51 AC 32 ms
34,616 KB
testcase_52 WA -
testcase_53 AC 33 ms
34,628 KB
testcase_54 AC 33 ms
34,660 KB
testcase_55 AC 33 ms
34,588 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 33 ms
34,760 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint d, l, r, k;

const int FACT_MAX = 2000005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint get(llint x)
{
	llint ret = 0;
	for(;x;x/=2) ret++;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> d >> l >> r >> k;
	make_fact();
	
	llint ans = 1;
	for(int i = 1; i <= d; i++) ans *= fact[1<<(i-1)], ans %= mod;
	//cout << ans << endl;
	
	llint dl = get(l), dr = get(r);
	if((dl+dr-k) % 2){
		cout << 0 << endl;
		return 0;
	}
	llint da = (dl+dr-k) / 2, f = dr - da;
	if(da > min(dl, dr)){
		cout << 0 << endl;
		return 0;
	}
	//cout << dl << " " << dr << " " << da << endl;
	
	if(dl != dr) ans *= 1<<f, ans %= mod, ans *= modpow(1<<(dr-1), mod-2), ans %= mod;
	else ans *= 1<<(f-1), ans %= mod, ans *= modpow((1<<(dr-1))-1, mod-2), ans %= mod;
	cout << ans << endl;
	
	return 0;
}
0