Kirisama @ 2021-11-03 23:31:08
#include<iostream>
using namespace std;
int main()
{int k,r=0;
cin>>k;
for(int i=1;k-i>=0;i++)
{r=r+k;
k=k-i;}
cout<<r;
return 0;}
by loris @ 2021-11-03 23:37:58
不开longlong见祖宗
by loris @ 2021-11-03 23:42:52
#include<iostream>
using namespace std;
int main()
{long long k,r=0;
cin>>k;
for(int i=1;k-i>=0;i++)
{r=r+k;
k=k-i;}
cout<<r;
return 0;}
你这码风也是够神奇
by Bread_m @ 2021-11-04 06:55:58
码风奇特
不开long long见祖宗
#include<iostream>
using namespace std;
int main()
{long long k,r=0;
cin>>k;
for(int i=1;k-i>=0;i++)
{r=r+k;k=k-i;}
cout<<r;
return 0;}
by RevolutionBP @ 2021-11-04 08:03:48
我超,然
by Kirisama @ 2021-11-04 12:36:16
@loris 也不对啊
by Kirisama @ 2021-11-04 12:40:24
@loris 码风是啥啊??真不知道
by sxf2113427 @ 2021-11-04 19:59:01
看看是不是理解错题意了
by 小鲤鱼666 @ 2021-11-09 12:09:18
最后不足i个数也要考虑进去,result += (k - (count - i)) *i
by Leave旭日冬升 @ 2021-12-02 20:36:50
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;
cin>>k;
int n=1,p=1;
int sum=0;
while(p<=k)
{
for(int i=1;i<=n;i++)
{
sum+=n;
if(p+1<=k) p++;
else
{
p+=1;
break;
}
}
n+=1;
}
cout<<sum;
return 0;
}