use std::io::{Read, stdin}; use std::cmp::{max, min}; struct XorShift { x: u32, y: u32, z: u32, w: u32 } impl XorShift { fn new(seed: u32) -> XorShift { XorShift{ x: seed, y: 1, z: 2, w: 3 } } fn generate(&mut self) -> u32 { let t = self.x ^ (self.x << 11); self.x = self.y; self.y = self.z; self.z = self.w; self.w = (self.w ^ (self.w >> 19)) ^ (t ^ (t >> 8)); self.w } } fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut tok = buf.split_whitespace(); let mut get = || tok.next().unwrap(); macro_rules! get { ($t:ty) => (get().parse::<$t>().unwrap()); () => (get!(i64)); } let n = 10_000_001; let seed = get!(u32); let mut rand = XorShift::new(seed); let mut max_value = 0; let mut min_value = std::u32::MAX; for _ in 0..n { let x = rand.generate(); max_value = max(max_value, x); min_value = min(min_value, x); } let div_line = (n + 1) / 2; let mid_value = (max_value - min_value) / 2 + min_value; let mut less_count = 0; let mut more_count = 0; rand = XorShift::new(seed); for _ in 0..n { let x = rand.generate(); if min_value <= x && x < mid_value { less_count += 1; } else if mid_value <= x && x <= max_value { more_count += 1; } } let mut arr = vec![]; if div_line <= less_count { rand = XorShift::new(seed); for _ in 0..n { let x = rand.generate(); if min_value <= x && x < mid_value { arr.push(x); } } arr.sort(); println!("{}", arr[div_line as usize]); } else if div_line <= more_count { rand = XorShift::new(seed); for _ in 0..n { let x = rand.generate(); if mid_value <= x && x <= max_value { arr.push(x); } } arr.sort(); arr.reverse(); println!("{}", arr[div_line as usize]); } }