結果
| 問題 |
No.1286 Stone Skipping
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2020-11-13 22:24:57 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,202 bytes |
| コンパイル時間 | 12,596 ms |
| コンパイル使用メモリ | 383,596 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-22 21:18:04 |
| 合計ジャッジ時間 | 13,917 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 2 |
ソースコード
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let d: i64 = rd.get();
for y in ((d / 2 - 100000)..=(d / 2 + 100000)).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.")
}
}
ikd