結果

問題 No.916 Encounter On A Tree
ユーザー ks2mks2m
提出日時 2019-10-25 23:01:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,305 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 74,160 KB
実行使用メモリ 55,788 KB
最終ジャッジ日時 2023-10-11 07:53:35
合計ジャッジ時間 7,040 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,056 KB
testcase_01 AC 44 ms
49,096 KB
testcase_02 AC 43 ms
49,308 KB
testcase_03 AC 65 ms
55,152 KB
testcase_04 AC 44 ms
49,512 KB
testcase_05 WA -
testcase_06 AC 44 ms
49,040 KB
testcase_07 AC 63 ms
55,448 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 44 ms
49,104 KB
testcase_11 AC 44 ms
49,120 KB
testcase_12 AC 44 ms
49,676 KB
testcase_13 AC 63 ms
55,500 KB
testcase_14 AC 44 ms
49,288 KB
testcase_15 AC 63 ms
55,568 KB
testcase_16 AC 43 ms
49,068 KB
testcase_17 WA -
testcase_18 AC 44 ms
49,304 KB
testcase_19 AC 63 ms
55,388 KB
testcase_20 AC 44 ms
49,236 KB
testcase_21 WA -
testcase_22 AC 43 ms
49,180 KB
testcase_23 WA -
testcase_24 AC 44 ms
50,992 KB
testcase_25 AC 63 ms
55,428 KB
testcase_26 AC 44 ms
49,460 KB
testcase_27 AC 55 ms
50,028 KB
testcase_28 AC 44 ms
49,588 KB
testcase_29 WA -
testcase_30 AC 43 ms
49,088 KB
testcase_31 AC 43 ms
49,080 KB
testcase_32 AC 42 ms
49,384 KB
testcase_33 AC 43 ms
47,232 KB
testcase_34 AC 50 ms
50,192 KB
testcase_35 AC 44 ms
49,100 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 44 ms
49,104 KB
testcase_40 WA -
testcase_41 AC 44 ms
49,376 KB
testcase_42 AC 44 ms
49,292 KB
testcase_43 AC 44 ms
49,068 KB
testcase_44 AC 44 ms
49,072 KB
testcase_45 AC 48 ms
49,196 KB
testcase_46 AC 44 ms
51,140 KB
testcase_47 AC 43 ms
49,120 KB
testcase_48 AC 43 ms
49,192 KB
testcase_49 AC 44 ms
49,288 KB
testcase_50 AC 44 ms
49,128 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 43 ms
49,444 KB
testcase_54 AC 43 ms
49,172 KB
testcase_55 AC 43 ms
49,744 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int d = Integer.parseInt(sa[0]);
		int l = Integer.parseInt(sa[1]);
		int r = Integer.parseInt(sa[2]);
		int k = Integer.parseInt(sa[3]);
		br.close();

		int dl = 1;
		for (int i = 1; i <= d; i++) {
			if ((1 << i) > l) {
				dl = i;
				break;
			}
		}
		int dr = 1;
		for (int i = 1; i <= d; i++) {
			if ((1 << i) > r) {
				dr = i;
				break;
			}
		}

		if (dr - dl <= k && k <= (dl + dr - 2) && (dr - dl) % 2 == k % 2) {
			int mod = 1000000007;
			int end = 1 << (d - 1);
			long[] p = new long[end + 1];
			p[0] = 1;
			for (int i = 1; i < p.length; i++) {
				p[i] = p[i - 1] * i % mod;
			}
			int k2 = k - (dr - dl);
			k2 /= 2;
			long ans = 1;
			for (int i = 0; i < d; i++) {
				if (dl > 1 && i + 1 == dr) {
					ans *= 1 << i;
					ans %= mod;
					if (k2 == 0) {
						ans *= 1 << (i - 1);
					} else {
						ans *= 1 << (k2 - 1);
					}
					ans %= mod;
					ans *= p[(1 << i) - 2];
				} else {
					ans *= p[1 << i];
				}
				ans %= mod;
			}
			System.out.println(ans);
		} else {
			System.out.println(0);
		}
	}
}
0