結果

問題 No.916 Encounter On A Tree
ユーザー ks2mks2m
提出日時 2019-10-25 22:57:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,236 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 73,412 KB
実行使用メモリ 56,008 KB
最終ジャッジ日時 2023-10-11 07:35:52
合計ジャッジ時間 7,724 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,296 KB
testcase_01 AC 43 ms
49,256 KB
testcase_02 AC 42 ms
49,256 KB
testcase_03 AC 63 ms
53,804 KB
testcase_04 AC 42 ms
49,356 KB
testcase_05 WA -
testcase_06 AC 43 ms
49,700 KB
testcase_07 AC 63 ms
55,552 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 42 ms
49,380 KB
testcase_11 AC 42 ms
49,372 KB
testcase_12 AC 43 ms
49,196 KB
testcase_13 AC 62 ms
55,776 KB
testcase_14 AC 43 ms
49,380 KB
testcase_15 AC 62 ms
55,620 KB
testcase_16 AC 43 ms
49,340 KB
testcase_17 WA -
testcase_18 AC 43 ms
49,380 KB
testcase_19 AC 62 ms
55,572 KB
testcase_20 AC 43 ms
49,368 KB
testcase_21 WA -
testcase_22 AC 43 ms
49,244 KB
testcase_23 WA -
testcase_24 AC 43 ms
49,552 KB
testcase_25 AC 64 ms
56,008 KB
testcase_26 AC 43 ms
49,196 KB
testcase_27 AC 54 ms
52,548 KB
testcase_28 AC 43 ms
49,324 KB
testcase_29 WA -
testcase_30 AC 43 ms
47,528 KB
testcase_31 AC 44 ms
49,248 KB
testcase_32 AC 43 ms
49,816 KB
testcase_33 AC 43 ms
49,576 KB
testcase_34 AC 50 ms
50,376 KB
testcase_35 AC 46 ms
49,464 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 44 ms
49,296 KB
testcase_40 WA -
testcase_41 AC 43 ms
49,440 KB
testcase_42 AC 43 ms
49,472 KB
testcase_43 AC 43 ms
49,496 KB
testcase_44 AC 42 ms
49,196 KB
testcase_45 AC 46 ms
49,256 KB
testcase_46 AC 43 ms
49,320 KB
testcase_47 AC 43 ms
49,348 KB
testcase_48 AC 43 ms
49,296 KB
testcase_49 AC 43 ms
49,256 KB
testcase_50 AC 44 ms
49,192 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 43 ms
49,480 KB
testcase_54 AC 42 ms
49,316 KB
testcase_55 AC 42 ms
49,324 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;
					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