結果
問題 |
No.1187 皇帝ペンギン
|
ユーザー |
|
提出日時 | 2020-08-22 14:22:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 1,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 2,371 ms |
コンパイル使用メモリ | 192,852 KB |
最終ジャッジ日時 | 2025-01-13 08:39:17 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 54 |
ソースコード
#include <bits/stdc++.h> namespace solver{ bool query(int x){ std::cout << "? " << x << "\n"; std::string ret; std::cin >> ret; if(ret == "safe") return true; else return false; } void answer(int x){ std::cout << "! " << x << "\n"; } void solve(){ int N, D = 0; int lb = 0, ub = 1001; while(abs(lb - ub) > 1){ int mid = (lb + ub) / 2; if(query(mid)){ lb = mid; }else{ if(query(mid + 1)){ lb = mid; D = std::gcd(D, mid); }else{ ub = mid; } } } N = ub; std::cerr << N << " " << D << "\n"; int ans = 0; for(int i = 0; i < N; ++i){ if(D == 0 or i % D != 0){ ans = std::max(ans, i); } } answer(ans); } } int main(){ solver::solve(); return 0; }