NOIP201501 Gold Coins

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.