結果
| 問題 |
No.253 ロウソクの長さ
|
| コンテスト | |
| ユーザー |
158b
|
| 提出日時 | 2015-07-24 23:52:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 1,209 bytes |
| コンパイル時間 | 628 ms |
| コンパイル使用メモリ | 75,472 KB |
| 実行使用メモリ | 25,460 KB |
| 平均クエリ数 | 21.64 |
| 最終ジャッジ日時 | 2024-07-16 20:49:53 |
| 合計ジャッジ時間 | 3,414 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:20: warning: overflow in conversion from ‘long int’ to ‘int’ changes value from ‘10000000001’ to ‘1410065409’ [-Woverflow]
24 | int maxd = 10000000001;
| ^~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
using namespace std;
//#define __int64 long long
//#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vecy[4] = {0,-1,0,1};
const int Vecx[4] = {1,0,-1,0};
int main(){
int ans;
int mind = 0;
int maxd = 10000000001;
int check;
int result;
int i = 0;
cout << "? " << 100 << endl;
cin >> result;
if(result == 0){
cout << "! 100" << endl;
return 0;
}
if(result == -1){
//100以下用
mind = 0;
maxd = 100;
for(i=1; i<100; i++){
check = (mind + maxd) / 2;
cout << "? " << (check - i) << endl;
cin >> result;
if(result == 0){
break;
}
if(result == -1){
maxd = check;
}else{
mind = check;
}
}
cout << "! " << check << endl;
return 0;
}
for(i=1; i<100; i++){
check = (mind + maxd) / 2;
cout << "? " << (check - i) << endl;
cin >> result;
if(result == 0){
break;
}
if(result == -1){
maxd = check;
}else{
mind = check;
}
}
cout << "! " << check << endl;
return 0;
}
158b