系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#20628 | #1028. 小秋的完美数字 | Accepted | 100 | 23 ms | 6 K | C++ 11 / 573 B | JM233333 | 2019-07-27 17:45:35 |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
// freopen("test.txt", "r", stdin);
int left = 1, right = 1e9;
while (left <= right) {
// 二分
int mid = (left + right) / 2;
// 输出:发起询问
printf("%d\n", mid);
fflush(stdout);
// 输入:获取结果
int x;
scanf("%d", &x);
// 完成的情况
if (x == 0) {
break;
}
// 二分
if (x < 0) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return 0;
}