結果

問題 No.2753 鳩の巣原理
ユーザー ttkkggww
提出日時 2024-05-14 13:54:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 490 bytes
コンパイル時間 4,141 ms
コンパイル使用メモリ 249,976 KB
最終ジャッジ日時 2025-02-21 14:01:41
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int N;

void solve(){
	ll ok = 1,ng = N;
	while(abs(ok-ng)>1){
		ll mid = (ok+ng)/2;
		ll in;
		cout<< "? " << mid << endl;
		cout<< flush;
		cin >> in;
		if(in == mid) {
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout<<"Yes "<<ok <<' '<<ng<<endl;
	cout<< flush;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
}
0