京东疯狂数列
#include <iostream>
#include <cmath>
using namespace std;
int main() {
unsigned long long n;
cin >> n;
//设第n个数为x,则x*(x+1)/2 = n,求解x, 得到 res = (-1 + sqrt(1 + 8 * n)) / 2;
int res = ceil((-1 + sqrt(1 + 8 * n)) / 2);
cout << res << endl;
return 0;
}
#京东##C++工程师#
查看7道真题和解析
