###### hdu 1001
Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).

In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.

Input
The input will consist of a series of integers n, one integer per line.

Output
For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.

Sample Input
1
100

Sample Output
1

5050

#include<iostream>
using namespace std;
int main(){
int n;
while(cin>>n){
if(n%2 == 0) //注意：题目要求不能超出32bit，但是n*(n+1)会超出范围，所以的先除2！
{cout<<(n/2)*(n+1)<<endl<<endl;}
else
{cout<<((n+1)/2)*n<<endl<<endl;}
}
return 0;
}

#### HDU 1001Sum Problem（入门题，C，Java两个版本）

2016-02-23 19:05:17

#### hdu 1001 java

2014-01-21 22:45:01

#### 杭电acm 1001

2012-10-07 12:49:52

#### hdu 1001 Java大数简单方法

2015-10-06 23:41:14

#### hdu1238Substrings

2016-08-01 15:04:33

#### hdu1238（Substrings）

2016-06-11 10:30:03

#### 杭电1398 Square Coins（母函数）

2014-08-08 21:38:39

#### HDU 1398-Square Coins （母函数）

2015-04-19 10:29:52

#### 杭电OJ分类题目（2）

2018-02-25 12:05:37

#### 【基础编程】hdu题目分类

2016-10-10 17:07:30

hdu 1001