Gold Coins

http://poj.org/problem?id=2000

View Code
#include<stdio.h>
int main()
{
    int n, i ;
    int a[10010]={0}, days=0, coins=1;
    while(days<10000)
    {
        i = coins ;
      while(i--)
        {
            days++ ;
            a[days] = a[days-1] + coins ;
         if(days==10000)
            break ;
        }
        coins++ ;
    }
    while(scanf("%d", &n), n!=0)
    {
        printf("%d %d\n", n, a[n]) ;
    }
    return 0 ;
}

 

posted @ 2013-04-10 18:03  yelan@yelan  阅读(145)  评论(0编辑  收藏  举报