結果

問題 No.916 Encounter On A Tree
ユーザー FF256grhyFF256grhy
提出日時 2019-10-26 01:13:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,359 bytes
コンパイル時間 1,425 ms
コンパイル使用メモリ 163,552 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 13:38:11
合計ジャッジ時間 3,831 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,352 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,352 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 1 ms
4,352 KB
testcase_34 AC 1 ms
4,348 KB
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,352 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 1 ms
4,348 KB
testcase_40 AC 1 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 1 ms
4,348 KB
testcase_43 AC 1 ms
4,348 KB
testcase_44 AC 1 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 1 ms
4,348 KB
testcase_47 AC 1 ms
4,348 KB
testcase_48 AC 1 ms
4,348 KB
testcase_49 AC 2 ms
4,352 KB
testcase_50 AC 1 ms
4,348 KB
testcase_51 AC 1 ms
4,352 KB
testcase_52 AC 1 ms
4,348 KB
testcase_53 AC 1 ms
4,352 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 AC 1 ms
4,348 KB
testcase_57 AC 2 ms
4,352 KB
testcase_58 AC 1 ms
4,352 KB
testcase_59 AC 1 ms
4,348 KB
testcase_60 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define ef else if

const int MOD = 1'000'000'007;
LL p[] = { 1, 2, 48, 1935360, 187767522, 588272078, 968309376, 754829929, 796867150, 94305900, 797182173, 825553566, 800802892, 622822155, 398493013, 843531154, 634777479, 233483695, 319671727, 608676892 };
LL x[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288 };
LL y[] = { 1, 500000004, 250000002, 125000001, 562500004, 281250002, 140625001, 570312504, 285156252, 142578126, 71289063, 535644535, 767822271, 883911139, 941955573, 970977790, 485488895, 742744451, 871372229, 935686118 };
LL z[] = { 0, 1, 333333336, 142857144, 466666670, 129032259, 15873016, 480314964, 556862749, 344422703, 94819160, 974596978, 492551896, 527652305, 840932680, 403149513, 243411919, 219232326, 372991080, 254269133 };

int main() {
	int d, l, r, k;
	scanf("%d%d%d%d", & d, & l, & r, & k);
	l = 32 - __builtin_clz(l) - 1;
	r = 32 - __builtin_clz(r) - 1;
	
	LL ans = 0;
	if(r - l <= k && k <= l + r && (l + r + k) % 2 == 0) {
		ans = p[d - 1];
		int m = (l + r - k) / 2;
		if(l == r) { (ans *= x[r - m - 1] * z[r] % MOD) %= MOD; }
		ef(l == m) { (ans *= x[r - m - 0] * y[r] % MOD) %= MOD; }
		else       { (ans *= x[r - m - 1] * y[r] % MOD) %= MOD; }
	}
	printf("%lld\n", ans);
	
	return 0;
}
0