jd 疯狂数列 10行KO
#include<iostream>
#include<cmath>
using namespace std;
int main(int argc,char* argv[]){
int n;
cin>>n;
int tmp = sqrt(2*n);
int low = tmp* (tmp -1) /2, high = low + tmp; //边界情况
while(n <= low || n > high){
if(n > high) ++tmp;
else --tmp;
low = tmp* (tmp -1) /2;
high = low + tmp;
}
cout<<tmp;
return 0;
}

三奇智元机器人科技有限公司公司福利 64人发布