結果

問題 No.63 ポッキーゲーム
ユーザー yo-kondo
提出日時 2019-03-30 09:53:14
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 708 bytes
コンパイル時間 23,612 ms
コンパイル使用メモリ 388,192 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 02:19:57
合計ジャッジ時間 14,836 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::stdin;

fn main() {
    let in1 = read_line();
    println!("{}", pocky(in1));
}

fn pocky(length_and_gnaw: String) -> i32 {
    let sp: Vec<&str> = length_and_gnaw.split_whitespace().collect();
    let length: i32 = sp[0].trim().parse().unwrap();
    let gnaw: i32 = sp[1].trim().parse().unwrap();

    let mut count = length / (gnaw * 2);
    let rem = length % (gnaw * 2);
    if rem == 0 {
        // ちょうど割り切れた場合はかじるのをやめるため、-1
        count -= 1;
    }
    count * gnaw
}

/// 標準入力から1行取得して返します。
fn read_line() -> String {
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    input
}
0