Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
绝对通俗……0ms#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator