AC代码:
#include <iostream> #include <cstdio> using namespace std; int main(void) { freopen("in.txt","r",stdin); long long n; while(scanf("%lld",&n)!=EOF) { if(n%2==0) printf("%lld ",n/2*(n+1)); else printf("%lld ",(n+1)/2*n); } fclose(stdin); return 0; }