牛客OI赛制测试赛2 D :星光晚餐

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37960603/article/details/82496044

题目传送门
看出规律,再二分即可
代码:

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

int main(){

    LL n;
    scanf("%lld",&n);
    int l=0,r=1e9,node;
    while(l<r){

        int mid=(l+r)>>1;
        if(1LL*mid*mid<=n) l=mid+1,node=mid;
        else r=mid-1;
    }
    printf("%d\n",node);
}

猜你喜欢

转载自blog.csdn.net/qq_37960603/article/details/82496044
今日推荐