結果
問題 |
No.257 N言っちゃダメゲーム (3)
|
ユーザー |
|
提出日時 | 2018-10-13 22:37:07 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 808 bytes |
コンパイル時間 | 13,785 ms |
コンパイル使用メモリ | 399,088 KB |
実行使用メモリ | 43,300 KB |
最終ジャッジ日時 | 2024-07-16 16:14:40 |
合計ジャッジ時間 | 20,497 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 29 |
ソースコード
#![allow(non_snake_case)] use std::io::{ self, prelude::* }; fn readline() -> String { let mut s = String::new(); io::stdin().read_line(&mut s).expect("i/o error"); s.trim().to_owned() } fn recv() -> i64 { readline().parse().unwrap() } fn send(x: i64) { println!("{}", x); io::stdout().flush().expect("i/o error"); } fn main() { let line = readline(); let mut tokens = line.split_whitespace(); let N: i64 = tokens.next().unwrap().parse().unwrap(); let K: i64 = tokens.next().unwrap().parse().unwrap(); let R = (N-1) % (K+1); let mut x = if R == 0 { 0 } else { R }; if x != 0 { send(x); } loop { let y = recv(); if y >= N { break; } assert!(x+1 <= y && y <= x+K); x += K+1; send(x); } }