結果

問題 No.2252 Find Zero
ユーザー Lanatus
提出日時 2023-03-24 21:54:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 425 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 66,048 KB
最終ジャッジ日時 2025-02-11 17:15:38
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main(void) {
  int n;
  cin >> n;

  for (int i = 0; i < n/2; ++i) {
    int a = i * 2;
    int b = i * 2 + 1;

    cout << "? " << a << " " << b << endl;

    int z;
    cin >> z;

    if (b == z) {
      cout << "! " << a << endl;
      return 0;
    } else if (a == z) {
      cout << "! " << b << endl;
      return 0;
    }
  }

  cout << "! " << n-1 << endl;
  return 0;
}
0