結果

問題 No.63 ポッキーゲーム
ユーザー t__nabet__nabe
提出日時 2020-04-10 18:21:05
言語 Rust
(1.77.0)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 913 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 137,736 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 10:28:09
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 3 ms
4,352 KB
testcase_11 AC 190 ms
4,352 KB
testcase_12 AC 4 ms
4,352 KB
testcase_13 AC 188 ms
4,348 KB
testcase_14 AC 5 ms
4,352 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 178 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 26 ms
4,352 KB
testcase_20 AC 4 ms
4,352 KB
testcase_21 AC 9 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `BufRead`
 --> Main.rs:2:22
  |
2 | use std::io::{Stdin, BufRead};
  |                      ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `stdin`
  --> Main.rs:33:15
   |
33 | fn read_input(stdin: &mut Stdin) -> Input {
   |               ^^^^^ help: if this is intentional, prefix it with an underscore: `_stdin`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted

ソースコード

diff #

use std::io;
use std::io::{Stdin, BufRead};


struct Input {
    l: u32,
    k: u32,
}


fn main() {
    let mut stdin = io::stdin();
    let input = read_input(&mut stdin);

    let mut pocky_length = input.l;
    let one_bite = input.k;

    let mut bite_count = 0;

    loop {
        if pocky_length <= one_bite * 2 {
            break;
        }
        pocky_length -= one_bite * 2;
        bite_count += 1;
    }

    let yu_bite = bite_count * one_bite;
    println!("{}", yu_bite);
}


fn read_input(stdin: &mut Stdin) -> Input {
    let vec = read_vec();

    Input { l: vec[0], k: vec[1] }
}

fn read_single<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_single::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
0