結果

問題 No.1187 皇帝ペンギン
ユーザー iqueue02iqueue02
提出日時 2020-08-22 15:17:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 202,468 KB
実行使用メモリ 24,228 KB
平均クエリ数 34.43
最終ジャッジ日時 2023-09-24 06:08:34
合計ジャッジ時間 6,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main() {
  vector<int> ok(1001, 1);
  string ret = "";
  int x = 100000;
  for (int i = 2; i <= 1000; i++) {
    if (!ok[i]) continue;
    for (int j = i; j <= 1000; j += i) ok[j] = 0;
    cout << "? ";
    cout << i << endl;
    cout.flush();
    cin >> ret;
    if (ret == "out") {
      x = i;
      break;
    }
  }

  vector<int> v;
  v.emplace_back(0);
  for (int i = 1; i <= 1000; i++) if (i % x != 0) v.emplace_back(i);

  int l = -1, r = v.size();

  while ( r - l > 1) {
    int m = (r + l) / 2;
    cout << "? ";
    cout << v[m];
    cout.flush();
    cin >> ret;
    if (ret == "out") r = m;
    else l = m;
  }
  cout << "! ";
  cout << v[l] << endl;
  return 0;
}
0