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 tankadozmy at 2010-02-08 11:41:34 on Problem 2000
#include<iostream>
using namespace std;
int main()
{
    int n,c_n,i,coin=0;
    while(cin>>n)
    {
        if(n==0) break;
        i=1; coin=0; c_n=n;
        while(1)
        {
            if(n-i<=0) {coin+=n*i; break;}
            else coin+=i*i;
            n-=i ;
            i++;
        }
        cout<<c_n<<" "<<coin<<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