20101104LiZhenyang @ 2023-09-21 23:25:03
#include<iostream>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
int ans=0;
int benci=0;
for(int i=1;i<=n;i++)
{
++benci;
for(int j=1;j<=benci;j++)
{
if(j+i<=n)
break;
ans+=benci;
}
}
printf("%d\n",ans);
return 0;
}
by yanlin123 @ 2023-10-15 09:24:37
#include<iostream>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
int ans=0;
int benci=0;
for(int i=1;i <= n;)
{
++benci;
for(int j=1;j<=benci && i <= n;j++, i++)
{
ans+=benci;
}
}
printf("%d\n",ans);
return 0;
}