結果

問題 No.916 Encounter On A Tree
ユーザー leaf_1415leaf_1415
提出日時 2019-10-25 21:54:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,299 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 53,196 KB
実行使用メモリ 34,868 KB
最終ジャッジ日時 2023-10-01 00:37:50
合計ジャッジ時間 4,967 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
	//cout << dl << " " << dr << " " << da << endl;
	
	if(dl != dr) ans *= 1<<(f-1), 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