最后一个点50问之内出不来??

P1733 猜数(IO交互版)

@[GeneralProgrammerVic](/user/482138) 比如 $n=10^9$,它就挂了。
by 035966_L3 @ 2022-06-29 17:05:07


@[GeneralProgrammerVic](/user/482138) 试试这个? ```cpp /*[Line 6]*/ int n, uprlmt = 1e9 + 1, lwrlmt = 0, curr; ```
by 035966_L3 @ 2022-06-29 17:08:13


@[GeneralProgrammerVic](/user/482138) ?????
by 蒟酱 @ 2022-06-29 17:08:28


@[GeneralProgrammerVic](/user/482138) 果然,直接输出 $10^9$ 能让最后一个点 AC。
by 035966_L3 @ 2022-06-29 17:09:49


@[蒟酱](/user/310818) ?
by ProgrammerVic @ 2022-06-29 17:13:54


@[035966_L3](/user/365654) 哦!!!!!!
by ProgrammerVic @ 2022-06-29 17:14:59


@[035966_L3](/user/365654) ```cpp #include <iostream> using namespace std; int main() { int n, uprlmt = 1e9, lwrlmt = 1, curr; while (true) { curr = (uprlmt + lwrlmt) / 2; cout << curr << endl; cin >> n; if (curr == uprlmt - 1 and n == -1) { cout << uprlmt; return 0; } if (n == 0) { return 0; } (n == -1 ? lwrlmt : uprlmt) = curr; } } ``` 这样就行了!!!我把-1写成1了!!!!!!
by ProgrammerVic @ 2022-06-29 17:15:30


!!!!!!??????
by 035966_L3 @ 2022-06-29 17:18:16


+1
by duck_catch_fishs @ 2022-10-06 14:57:18


@[GeneralProgrammerVic](/user/482138) 我是这样写的: ```c++ #include <bits/stdc++.h> using namespace std; int main() { int left=1,right=1e9+1; int res; while (true) { cout<<(left+right)/2<<endl; cin>>res; if (res==-1) { left=(left+right)/2; } else if (res==1) { right=(left+right)/2; } else { return 0; } } return 0; } ``` right初始化为1e9时最后一个点TLE,right为1e9+1时AC 玄学问题。。。
by Lele_Programmer @ 2023-07-14 21:38:14


| 下一页