c++
2025-07-22 18:09:55
发布于:广西
0阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main(){
int k;
cin >> k;
int m =0;
int sum_m = 0;
while (sum_m + m +1<= k){
m++;
sum_m = sum_m + m;
}
long long square_m = (long long)m * (m + 1) * (2 * m + 1) / 6;
int rem = k - sum_m;
long long total = square_m + rem * (m+1);
cout << total <<endl;
return 0;
}
这里空空如也
有帮助,赞一个