結果
| 問題 |
No.63 ポッキーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 18:21:05 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 190 ms / 5,000 ms |
| コード長 | 913 bytes |
| コンパイル時間 | 12,731 ms |
| コンパイル使用メモリ | 378,228 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 07:33:13 |
| 合計ジャッジ時間 | 14,382 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
コンパイルメッセージ
warning: unused import: `BufRead`
--> src/main.rs:2:22
|
2 | use std::io::{Stdin, BufRead};
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused variable: `stdin`
--> src/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
ソースコード
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()
}