HD1001

来源:互联网 发布:海王星2.0软件下载 编辑:程序博客网 时间:2024/05/16 19:00
杭电ACM 2014暑期集训队——选拔安排~

第一种AC,第二种可能会造成溢出。

解题关键点:

1、注意溢出,应先判断奇偶

2 the range of32-bit signed integer32位符号有效范围

3、样例中输出是隔行的


Sum Problem

Time Limit: 1000/500 MS (Java/Others)    Mem
ory Limit: 65536/32768 K (Java/Others)Total Submission(s): 266380    Accepted Submission(s): 66255
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