LMR_Minecraft @ 2024-02-24 17:24:43
#include<bits/stdc++.h>
using namespace std;
int main(){
int k,jd=0,x=1,y=0,gz,ts,ans=0;
cin>>k;
int n[10005];
while(x<=k){
k=k-x;
y++;
x++;
}
for(int jd=0;jd<=y;jd++){
for(int ts=1;ts<=jd;ts++){
gz=jd;
ans=ans+gz;
}
}
cout<<ans;
return 0;
}
by 0v_0___SYC @ 2024-02-24 17:55:43
@LMR_ 你有没有考虑过如16这样的数据,16=1+2+3+4+5+1,你没有加上多余的天数。
by 0v_0___SYC @ 2024-02-24 17:56:18
@LMR_ ac代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int k,jd=0,x=1,y=0,gz=0,ts=0,ans=0;
cin>>k;
int n[10005];
while(x<=k){
k=k-x;
y++;
x++;
}
for(int jd=1;jd<=y;jd++){
for(int ts=1;ts<=jd;ts++){
ans=ans+jd;
}
}
ans+=(y+1)*k;
cout<<ans;
return 0;
}
by LMR_Minecraft @ 2024-02-24 18:12:38
@0v_0___SYC 哦
by HEROBRINEH @ 2024-02-24 18:13:58
#include <bits/stdc++.h>
using namespace std;
int main() {
int k;
cin >> k;
int sum = 0;
int an = 1;
int b = 0 ;
for(int i = 1 ; i <= k ; i++) {
k -= i;
b += an * an;
an ++;
}
cout << b + k * an;
}
by Andy_hpy @ 2024-08-09 11:07:46
#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;
}