結果
| 問題 |
No.253 ロウソクの長さ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-11 01:24:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 557 bytes |
| コンパイル時間 | 3,523 ms |
| コンパイル使用メモリ | 190,900 KB |
| 最終ジャッジ日時 | 2025-01-11 01:03:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 13 TLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int ask(int)’:
main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | int res; scanf("%d",&res);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int ask(int x){
printf("? %d\n",x);
fflush(stdout);
int res; scanf("%d",&res);
return res;
}
void answer(int x){
printf("! %d\n",x);
fflush(stdout);
}
int main(){
int res=ask(100);
if(res==0){
answer(100);
}
else if(res==-1){
int t;
for(t=1;ask(t)!=0;t++);
answer(t);
}
else{
int t=1;
int lo=100,hi=1e9;
while(hi-lo>1){
int mi=(lo+hi)/2;
if(ask(mi-t)!=-1) lo=mi;
else hi=mi;
t++;
}
answer(lo);
}
return 0;
}