题解 | #星际穿越#

星际穿越

http://www.nowcoder.com/practice/53e4c208b8cf497086ecd65ef45349bb

cin有位数限制, 省去了强制转换, pow也可以代替sqrt用

#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
    long long h;
    //cin>>h;位数限制6位
    scanf("%lld",&h);
    //x^2+x-h=0
    //= 1+4h
    //      -1+_pow(1+4h,0.5)/2
    long long k = (-1+pow(1+4*h,0.5))/2;
    printf("%lld",k);
    
    return 0;
}
全部评论

相关推荐

野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务