結果

問題 No.2252 Find Zero
ユーザー chro_96
提出日時 2023-03-24 21:26:05
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 1,024 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 25,580 KB
平均クエリ数 195.33
最終ジャッジ日時 2024-09-18 16:42:06
合計ジャッジ時間 3,188 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int z = 0;
  
  int res = 0;
  
  int ans = 0;
  
  res = scanf("%d", &n);
  
  ans = n-1;
  for (int i = 0; i < n/2; i++) {
    printf("? %d %d\n", 2*i, 2*i+1);
    fflush(stdout);
    res = scanf("%d", &z);
    if (z == 2*i) {
      ans = 2*i+1;
    } else if (z == 2*i+1) {
      ans = 2*i;
    }
  }
  
  printf("! %d\n", ans);
  return 0;
}
0