标签:
#include<stdio.h> int main(void) { unsigned n; while(scanf("%d", &n) != EOF) { printf("%d\n\n", (1+n)*n/2); } return 0; }
n+1可能出现溢出情况,所以需要将n的数据类型改为unsigned
HDOJ_1001
原文地址:http://www.cnblogs.com/L3i4c5x6/p/4660978.html