結果

問題 No.2753 鳩の巣原理
ユーザー Carpenters-Cat
提出日時 2024-05-10 22:00:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 1,785 ms
コンパイル使用メモリ 193,748 KB
最終ジャッジ日時 2025-02-21 12:45:22
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	int ok = 1, ng = N;
	for (int pkj = 0; pkj < 10; pkj ++) {
		if (abs(ok - ng) > 1) {
			int mu = (ok + ng) / 2;
			cout << "? " << mu << endl;
			int a;
			cin >> a;
			if (a < mu) {
				ng = mu;
			} else {
				ok = mu;
			}
		} else {
			cout << "? 1" << endl;
			int a;
			cin >> a;
		}
	}
	cout << "Yes " << ok << " " << ok + 1 << endl;
}
0