結果
問題 | No.670 log は定数 |
ユーザー |
![]() |
提出日時 | 2019-12-09 12:28:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1,480 ms / 4,000 ms |
コード長 | 1,299 bytes |
コンパイル時間 | 16,926 ms |
コンパイル使用メモリ | 386,648 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 00:34:05 |
合計ジャッジ時間 | 32,279 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
struct RNG {seed: usize,}impl RNG {fn new(seed: usize) -> Self {RNG {seed: seed,}}fn next(&mut self) -> usize {let x = &mut self.seed;*x = *x ^ (*x << 13);*x = *x ^ (*x >> 7);*x = *x ^ (*x << 17);*x >> 33}}fn run() {let mut s = String::new();std::io::stdin().read_line(&mut s).unwrap();let mut it = s.trim().split_whitespace();let n: usize = it.next().unwrap().parse().unwrap();let q: usize = it.next().unwrap().parse().unwrap();let seed: usize = it.next().unwrap().parse().unwrap();let rng = &mut RNG::new(seed);for _ in 0..10000 {rng.next();}let sup = 1usize << 31;let m = 1 << 16;let mut a = vec![vec![]; sup / m];for _ in 0..n {let v: usize = rng.next();a[v / m].push(v);}let mut cnt = vec![0; sup / m + 1];for i in (0..(sup / m)).rev() {cnt[i] = cnt[i + 1] + a[i].len();}let mut ans = 0;for i in 0..q {let x: usize = rng.next();let mut c = n - cnt[x / m];for &a in &a[x / m] {if a < x {c += 1;}}ans ^= c * i;}println!("{}", ans);}fn main() {run();}