感觉很简单吧??? #include<bits/stdc++.h> using namespace std; int s,n,m,i; int main() { 代码复制cin>>n; while(m<n) { i++; s+=i*i; m+=i; } s-=(m-n)*i; cout<<s; }