poj2000
简单题
#include <cstdio> #define maxn 10005 int n, f[maxn]; void init() { int i = 1; int x = 0; while (1) { for (int j = 0; j < i; j++) { x++; if (x > 10000) return; f[x] = f[x - 1] + i; } i++; } } int main() { init(); while (scanf("%d", &n), n) printf("%d %d\n", n, f[n]); return 0; }