The king paid the coins as wages to the loyal knight. On the first day, the knight received a gold coin, two days (the second day and the third day), received two gold coins per day, three days (iv days), three gold coins per day, then four days (第七、八、九、十 days), received four gold coins per day ... This pattern of wage payments continues: When n gold coins are received every day for successive n days, the knight receives n+1 coins every day for successive n+1 days.
Please calculate how many coins the knight received in the first K days.
Input
The input file is only 1 lines and contains a positive integer K, indicating the number of days to issue coins
Output
The output file is only 1 lines and contains a positive integer, which is the number of coins received by the knight
--------------------------------------------------------------------------------------------------------------- -----------------------------------
#include <iostream>
#include <cstdio>
using namespace Std;
int a[10000];
int main ()
{
int sum=1,t1=1,temp=0,ans=0,k,i;
scanf ("%d", &k);
for (i=1;i<=k;i++)
{
if (TEMP<T1)
{
A[i]=sum;
temp++;
}
if (TEMP==T1)
{
sum++;
t1++;
Temp=0;
}
}
for (i=1;i<=k;i++) ans+=a[i];
printf ("%d", ans);
System ("pause");
return 0;
}
NOIP201501 Gold Coins