結果
| 問題 |
No.246 質問と回答
|
| コンテスト | |
| ユーザー |
sino
|
| 提出日時 | 2020-04-17 23:14:22 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 2,000 ms |
| コード長 | 1,358 bytes |
| コンパイル時間 | 12,204 ms |
| コンパイル使用メモリ | 386,056 KB |
| 実行使用メモリ | 25,604 KB |
| 平均クエリ数 | 31.53 |
| 最終ジャッジ日時 | 2024-07-16 20:24:04 |
| 合計ジャッジ時間 | 15,346 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
#[allow(unused_macros)]
macro_rules! read {
([$t:ty] ; $n:expr) =>
((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
($($t:ty),+ ; $n:expr) =>
((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
([$t:ty]) =>
(rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
($t:ty) =>
(rl().parse::<$t>().unwrap());
($($t:ty),*) => {{
let buf = rl();
let mut w = buf.split_whitespace();
($(w.next().unwrap().parse::<$t>().unwrap()),*)
}};
}
#[allow(dead_code)]
fn rl() -> String {
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
buf.trim_end().to_owned()
}
fn main() {
use std::io::{self, Write};
let mut lb = 0u64;
let mut ub = 1000000000u64;
while ub - lb > 1 {
let q = (lb + ub) / 2;
println!("? {}", q);
io::stdout().flush().unwrap();
let react = read!(i32);
if react == 1 {
lb = q;
} else {
ub = q - 1;
}
}
println!("? {}", ub);
let react = read!(i32);
if react == 1 {
println!("! {}", ub);
}
else {
println!("! {}", lb);
}
}
sino