結果

問題 No.2753 鳩の巣原理
ユーザー aaaaaaaaaa2230
提出日時 2024-05-10 23:15:00
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 3,215 ms
コンパイル使用メモリ 243,048 KB
実行使用メモリ 25,532 KB
平均クエリ数 11.00
最終ジャッジ日時 2024-12-20 07:30:28
合計ジャッジ時間 5,735 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    int n;
    cin >> n;
    int l = 1,r = n;
    for (int i = 0; i < 10; i++){
        int m = (r+l)/2;
        cout << "? " << m << endl;
        int x;
        cin >> x;
        if (m > x){
            r = m;
        } else{
            l = m;
        }
    }
    cout << "Yes " << l << " " << r << endl;
    

    return 0;
}
0