Lbj080617 @ 2024-07-13 15:09:29
by czy032321054 @ 2024-07-13 15:31:04
#include<bits/stdc++.h>
using namespace std;
long long k,ans,z=1;
int main(){
cin>>k;
while(1){
ans+=min(z,k)*z;
k-=z;
if(k<=0)break;
z++;
}
cout<<ans;
}
by lrq666_ @ 2024-07-29 15:04:15
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
int sum=0;
int c=1;
for(int i=1;i<=a;i++){
a=a-i;
sum+=c*c;
c++;
}
cout<<sum+a*c;
return 0;
}
by Andy_hpy @ 2024-08-09 11:02:10
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
ll f1(ll n,ll s){
if(n<s)return n*s;
if(a[n]!=0)return a[n];
a[n]=s*s+f1(n-s,s+1);
return a[n];
}
ll f(ll n){return f1(n,1);}
int main(){
ll n;
cin>>n;
cout<<f(n);
return 0;
}