結果

問題 No.1429 Simple Dowsing
ユーザー akakimidori
提出日時 2024-09-15 19:45:23
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 24,776 ms
コンパイル使用メモリ 383,964 KB
実行使用メモリ 25,604 KB
平均クエリ数 3.00
最終ジャッジ日時 2024-09-15 19:45:49
合計ジャッジ時間 14,825 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read() -> usize {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().unwrap()
}

fn main() {
    let w = 100usize;
    let query = |x: usize, y: usize| -> usize {
        assert!(x <= w && y <= w);
        println!("? {} {}", x, y);
        read()
    };
    let a = query(0, 0);
    let b = query(100, 0);
    for i in 0..=w {
        for j in 0..=w {
            if i.pow(2) + j.pow(2) == a && (w - i).pow(2) + j.pow(2) == b {
                println!("! {} {}", i, j);
                return;
            }
        }
    }
}
0