标签:
#include<iostream> #include<cstdio> #define MAXN 10009 using namespace std; int a[MAXN+1]; int main() { //freopen("acm.acm","r",stdin); int i; int j = 1; int k = 0; a[0] = 0; for(i = 1; i <= MAXN; ++ i) { a[i] = j; a[i] = a[i-1] + a[i]; ++ k; if(k == j) { k = 0; ++ j; } } while(cin>>k,k) { cout<<k<<" "<<a[k]<<endl; } }
标签:
原文地址:http://www.cnblogs.com/gavinsp/p/4566610.html