宁波大学2018院赛 nbuoj2786 玻璃球

题目:http://www.nbuoj.com/v8.83/Problems/Problem.php?pid=2786

用2个玻璃球找到从一100层的大楼的某一层落下刚好会摔碎,如何制定最优策略?

别人的总结已经很(๑•̀ㅂ•́)و✧了

https://www.zhihu.com/question/27547892/answer/131239272

https://www.cnblogs.com/kuliuheng/p/11595153.html

代码很短,主要wa点在于有没有看出玻璃球碎了就不能再用,但是又一定要测出楼层数。(已经喊zmz改过题面啦)

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    while(cin>>n)
    {
        for(x=1;;x++)
        {
            if((x+1)*x/2>=n)
            break;
        }
        cout<<x<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/myrtle/p/11857166.html