結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー taotao54321taotao54321
提出日時 2018-10-13 22:41:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 140,376 KB
実行使用メモリ 24,384 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-24 01:59:02
合計ジャッジ時間 6,443 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
23,796 KB
testcase_01 AC 37 ms
24,132 KB
testcase_02 AC 40 ms
23,808 KB
testcase_03 AC 43 ms
23,364 KB
testcase_04 AC 39 ms
23,844 KB
testcase_05 AC 38 ms
24,276 KB
testcase_06 AC 42 ms
23,352 KB
testcase_07 AC 37 ms
23,400 KB
testcase_08 AC 41 ms
23,748 KB
testcase_09 AC 38 ms
23,328 KB
testcase_10 AC 37 ms
23,316 KB
testcase_11 AC 37 ms
23,616 KB
testcase_12 AC 38 ms
24,228 KB
testcase_13 AC 38 ms
24,000 KB
testcase_14 AC 44 ms
23,484 KB
testcase_15 AC 37 ms
23,892 KB
testcase_16 AC 40 ms
23,304 KB
testcase_17 AC 41 ms
24,276 KB
testcase_18 AC 39 ms
23,616 KB
testcase_19 AC 38 ms
24,384 KB
testcase_20 AC 38 ms
23,328 KB
testcase_21 AC 39 ms
24,012 KB
testcase_22 AC 39 ms
24,000 KB
testcase_23 AC 38 ms
23,748 KB
testcase_24 AC 38 ms
23,604 KB
testcase_25 AC 39 ms
24,228 KB
testcase_26 AC 39 ms
24,000 KB
testcase_27 AC 40 ms
24,216 KB
testcase_28 AC 38 ms
23,616 KB
testcase_29 AC 38 ms
24,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![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 mut x = (N-1) % (K+1);
    loop {
        send(x);

        let y = recv();
        if y >= N { break; }
        assert!(x+1 <= y && y <= x+K);

        x += K+1;
    }
}
0