結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
34,624 KB
testcase_01 AC 33 ms
34,836 KB
testcase_02 AC 33 ms
34,580 KB
testcase_03 WA -
testcase_04 AC 33 ms
34,580 KB
testcase_05 WA -
testcase_06 AC 33 ms
34,544 KB
testcase_07 WA -
testcase_08 AC 33 ms
34,812 KB
testcase_09 AC 33 ms
34,688 KB
testcase_10 AC 32 ms
34,640 KB
testcase_11 AC 32 ms
34,636 KB
testcase_12 AC 33 ms
34,628 KB
testcase_13 AC 33 ms
34,760 KB
testcase_14 AC 33 ms
34,576 KB
testcase_15 AC 33 ms
34,596 KB
testcase_16 AC 32 ms
34,668 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 33 ms
34,632 KB
testcase_21 WA -
testcase_22 AC 33 ms
34,688 KB
testcase_23 WA -
testcase_24 AC 33 ms
34,548 KB
testcase_25 WA -
testcase_26 AC 33 ms
34,640 KB
testcase_27 WA -
testcase_28 AC 33 ms
34,692 KB
testcase_29 WA -
testcase_30 AC 33 ms
34,620 KB
testcase_31 AC 33 ms
34,632 KB
testcase_32 AC 33 ms
34,640 KB
testcase_33 AC 33 ms
34,576 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 33 ms
34,640 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 33 ms
34,572 KB
testcase_40 AC 33 ms
34,564 KB
testcase_41 AC 32 ms
34,668 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 33 ms
34,756 KB
testcase_45 WA -
testcase_46 AC 32 ms
34,572 KB
testcase_47 AC 32 ms
34,584 KB
testcase_48 AC 32 ms
34,580 KB
testcase_49 AC 33 ms
34,824 KB
testcase_50 WA -
testcase_51 AC 32 ms
34,580 KB
testcase_52 WA -
testcase_53 AC 33 ms
34,548 KB
testcase_54 AC 32 ms
34,644 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 32 ms
34,632 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) || da < 1){
		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, ans %= mod, ans *= modpow((1<<(dr-1))-1, mod-2), ans %= mod;
	cout << ans << endl;
	
	return 0;
}
0