Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

根本没想那么多,打个表,0MS过……

Posted by xijunlee93 at 2013-03-29 21:49:41 on Problem 2000
#include<iostream>
#include<stdlib.h>
using namespace std;

long coin[10001];
int main()
{
     int i,k,j;
     long n,ans;
     k=1;j=0;
     for (i=1;i<=10000;i++)
     {
        if (j<k)
        {coin[i]=k;j++;}
        if (j>=k)
        {j=0;k++;}
     }
     while(cin>>n&&n!=0)
     {
        ans=0;
        for (j=1;j<=n;j++)
        ans+=coin[j];
        cout<<n<<" "<<ans<<endl;
     }
     return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator