wang0728 @ 2023-01-07 15:09:47
#include <bits/stdc++.h>//10000 942820
using namespace std;
long long a[100000],s,c;
int main()
{
int k;
cin>>k;
for(int i=1;i<=k;i++){
for(int j=1;j<=i;j++){
c++;
a[c]=i;
}
}
for(int i=1;i<=k;i++){
s+=a[i];
}
cout<<s;
return 0;
}
by Tangjiale @ 2023-01-07 15:28:56
#include <bits/stdc++.h>//10000 942820
using namespace std;
long long a[100000],s,c;
int main()
{
int k;
cin>>k;
for(int i=1;i<=k;i++){
for(int j=1;j<=i;j++){
c++;
a[c]=i;
if(c >= k) break;
}
}
for(int i=1;i<=k;i++){
s+=a[i];
}
cout<<s;
return 0;
}
by wang0728 @ 2023-01-18 11:10:13
@Tangjiale 100分