結果

問題 No.63 ポッキーゲーム
ユーザー YoshihitoYoshihito
提出日時 2020-04-10 18:17:40
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 3,405 ms
コンパイル使用メモリ 140,008 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 10:23:53
合計ジャッジ時間 4,347 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
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,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,352 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `remains`
  --> Main.rs:28:9
   |
28 |     let remains = input.l % input.k;
   |         ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_remains`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::io::{self, Read};

#[derive(Debug)]
struct Input {
    l: i32,
    k: i32,
}

fn next_token(cin_lock: &mut io::StdinLock) -> String {
    cin_lock
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
}

fn read_input(cin_lock: &mut io::StdinLock) -> Input {
    Input {
        l: next_token(cin_lock).parse().unwrap(),
        k: next_token(cin_lock).parse().unwrap(),
    }
}

fn solve(input: &Input, _cin_lock: &mut io::StdinLock) {
    let bites = input.l / input.k;
    let remains = input.l % input.k;

    let haruka_bites = (bites + 1) / 2;
    let yuu_bites = bites - haruka_bites;
    let ans = input.k * yuu_bites;
    println!("{}", ans);
}

fn main() {
    let cin = io::stdin();
    let mut cin_lock = cin.lock();

    let input = read_input(&mut cin_lock);
    solve(&input, &mut cin_lock);
}
0