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 ; }