結果
問題 | No.916 Encounter On A Tree |
ユーザー | phspls |
提出日時 | 2020-02-06 23:40:32 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,795 bytes |
コンパイル時間 | 12,645 ms |
コンパイル使用メモリ | 383,632 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 06:59:55 |
合計ジャッジ時間 | 14,409 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 6 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 6 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 5 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | WA | - |
testcase_12 | AC | 1 ms
6,940 KB |
testcase_13 | WA | - |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | WA | - |
testcase_16 | AC | 1 ms
6,944 KB |
testcase_17 | AC | 5 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,944 KB |
testcase_19 | AC | 5 ms
6,944 KB |
testcase_20 | AC | 1 ms
6,944 KB |
testcase_21 | AC | 6 ms
6,944 KB |
testcase_22 | AC | 0 ms
6,940 KB |
testcase_23 | AC | 6 ms
6,940 KB |
testcase_24 | AC | 1 ms
6,944 KB |
testcase_25 | AC | 6 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,944 KB |
testcase_27 | AC | 3 ms
6,940 KB |
testcase_28 | AC | 1 ms
6,940 KB |
testcase_29 | AC | 6 ms
6,944 KB |
testcase_30 | AC | 1 ms
6,940 KB |
testcase_31 | AC | 1 ms
6,944 KB |
testcase_32 | AC | 0 ms
6,944 KB |
testcase_33 | AC | 0 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 1 ms
6,944 KB |
testcase_36 | WA | - |
testcase_37 | AC | 6 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 1 ms
6,940 KB |
testcase_40 | WA | - |
testcase_41 | AC | 1 ms
6,940 KB |
testcase_42 | AC | 1 ms
6,940 KB |
testcase_43 | AC | 1 ms
6,944 KB |
testcase_44 | AC | 1 ms
6,944 KB |
testcase_45 | AC | 1 ms
6,944 KB |
testcase_46 | AC | 1 ms
6,944 KB |
testcase_47 | WA | - |
testcase_48 | AC | 1 ms
6,940 KB |
testcase_49 | WA | - |
testcase_50 | AC | 1 ms
6,944 KB |
testcase_51 | WA | - |
testcase_52 | AC | 0 ms
6,944 KB |
testcase_53 | WA | - |
testcase_54 | AC | 1 ms
6,940 KB |
testcase_55 | AC | 1 ms
6,940 KB |
testcase_56 | AC | 1 ms
6,940 KB |
testcase_57 | AC | 1 ms
6,940 KB |
testcase_58 | WA | - |
testcase_59 | AC | 1 ms
6,940 KB |
testcase_60 | AC | 1 ms
6,940 KB |
ソースコード
use std::io::Read; fn main() { const DIVIDER: usize = 1_000_000_007; let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let dlrk: Vec<usize> = all_data.trim().split('\n').next().unwrap().trim().split_whitespace() .map(|s| s.parse().unwrap()) .collect(); let d: usize = dlrk[0]; let l: usize = dlrk[1]; let r: usize = dlrk[2]; let k: usize = dlrk[3]; let mut l_count = 0; let mut r_count = 0; for i in 1..=d { if l < 2i32.pow(i as u32) as usize { l_count = i; break; } } for i in 1..=d { if r < 2i32.pow(i as u32) as usize { r_count = i; break; } } if l_count < r_count { if (r_count - l_count + k) % 2 == 1 { println!("{}", 0); } else if r_count - l_count > k || r_count + l_count - 2 < k { println!("{}", 0); } else { let mut result: usize = 1; for depth in 1..=d { if depth == r_count { for i in 1..(2i32.pow(depth as u32 -1)) { result *= i as usize; result %= DIVIDER; } if r_count - l_count == l { result *= 2i32.pow(r_count as u32 - l_count as u32) as usize; } else { result *= 2i32.pow(r_count as u32 - l_count as u32 + (k as u32 + l_count as u32 - r_count as u32) / 2 - 1u32) as usize; } result %= DIVIDER; } else { for i in 1..=(2i32.pow(depth as u32 -1)) { result *= i as usize; result %= DIVIDER; } } } println!("{}", result); } } else { if k < 2 || k % 2 != 0 || r_count + l_count - 2 < k { println!("{}", 0); } else { let mut result: usize = 1; for depth in 1..=d { if depth == r_count { for i in 1..(2i32.pow(depth as u32 -1) - 1) { result *= i as usize; result %= DIVIDER; } result *= 2i32.pow(depth as u32 -1) as usize; result %= DIVIDER; result *= 2i32.pow((k as u32) / 2 - 1) as usize; result %= DIVIDER; } else { for i in 1..=(2i32.pow(depth as u32 -1)) { result *= i as usize; result %= DIVIDER; } } } println!("{}", result); } } }