結果

問題 No.2357 Guess the Function
ユーザー tnakao0123tnakao0123
提出日時 2023-06-30 09:47:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 1,000 ms
コード長 591 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 40,188 KB
実行使用メモリ 24,372 KB
平均クエリ数 2.91
最終ジャッジ日時 2023-09-21 04:01:00
合計ジャッジ時間 1,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,424 KB
testcase_01 AC 25 ms
23,940 KB
testcase_02 AC 24 ms
23,832 KB
testcase_03 AC 24 ms
23,832 KB
testcase_04 AC 25 ms
23,952 KB
testcase_05 AC 24 ms
23,412 KB
testcase_06 AC 25 ms
24,156 KB
testcase_07 AC 25 ms
24,372 KB
testcase_08 AC 26 ms
24,036 KB
testcase_09 AC 25 ms
24,048 KB
testcase_10 AC 24 ms
23,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2357.cc:  No.2357 Guess the Function - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

int query(int x) {
  printf("? %d\n", x); fflush(stdout);

  int r;
  scanf("%d", &r);
  return r;
}

/* main */

int main() {
  int r0 = query(100);
  int a, b;
  
  if (r0 == 99) {
    a = 99, b = 100;
  }
  else {
    int r1 = query(99 - r0);
    b = r1 + 1;
    a = r0 - 100 % b;
    if (a < 0) a += b;
  }

  printf("! %d %d\n", a, b); fflush(stdout);
  return 0;
}
0