求代码

haimoxiaoen 2021-08-02 22:21:20 4

求代码,100分的代码,谢谢!

{{ vote && vote.total.up }}

共 1 条回复

HJC 黑铁V

#include <bits/stdc++.h>

using namespace std;

int main() { int k, i = 0, a = 0, b = 0; cin >> k; while (b <= k) { i++; a += i * i; b = (i + 1) * i / 2; } a -= (b - k) * i; cout << a; return 0; }