結果

問題 No.1286 Stone Skipping
ユーザー ikdikd
提出日時 2020-11-13 22:30:12
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,206 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 147,232 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-30 03:28:55
合計ジャッジ時間 14,720 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 551 ms
4,380 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 551 ms
4,380 KB
testcase_09 AC 549 ms
4,376 KB
testcase_10 AC 550 ms
4,380 KB
testcase_11 AC 550 ms
4,376 KB
testcase_12 AC 549 ms
4,380 KB
testcase_13 AC 549 ms
4,380 KB
testcase_14 AC 552 ms
4,376 KB
testcase_15 AC 549 ms
4,376 KB
testcase_16 AC 549 ms
4,380 KB
testcase_17 AC 550 ms
4,380 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 549 ms
4,380 KB
testcase_21 AC 549 ms
4,380 KB
testcase_22 AC 549 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 548 ms
4,376 KB
testcase_26 AC 550 ms
4,380 KB
testcase_27 AC 549 ms
4,380 KB
testcase_28 AC 549 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let d: i64 = rd.get();
    for y in ((d / 2 - 10000000)..=(d / 2 + 10000000)).filter(|&y| 1 <= y && y <= d) {
        if (0..60)
            .scan((0, y), |(s, x), _| {
                *s += *x;
                *x /= 2;
                Some((*s, *x))
            })
            .any(|(s, _)| s == d)
        {
            println!("{}", y);
            return;
        }
    }
    println!("{}", d);
}

pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}
0