大意略。
思路:切豆腐,3刀八块,关键是如何去切。f[n]-f[n-1] = n,f[0] = 1;
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <cstdio> #include <cmath> using namespace std; typedef long long LL; LL n; int main() { while(~scanf("%lld", &n)) { if(n < 0) break; printf("%lld\n", (n*n+n)/2+1); } return 0; }