系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#97498 | #1028. 小秋的完美数字 | Accepted | 100 | 21 ms | 384 K | C++ / 522 B | zjn | 2023-07-06 18:22:36 |
#include <iostream>
#include <cstdio>
int main() {
int low = 1, high = 1000000000;
int guess = (low + high) / 2;
int result;
while (true) {
std::cout << guess << std::endl;
fflush(stdout);
std::cin >> result;
if (result == 0) {
break;
} else if (result == 1) {
high = guess - 1;
} else if (result == -1) {
low = guess + 1;
}
guess = (low + high) / 2;
}
return 0;
}