# 题目信息
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 745568 Accepted Submission(s): 188863
# 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 | 1 |
# Sample Output
1 | 1 |
# 题解
# C 语言解法
1 |
|
# Be Careful
- 输出结果后要两个换行.
- 这道题一定不要使用等差数列求和。因为
n*(n+1)
会超时int
类型数值范围。
# 长点心吧
面前有两条路,中规中矩 and 捷径,是鼓励走捷径的。但是一定要确定捷径的结果是和另一条路是一模一样的。否则还是选择中规中矩的路吧。否则是会付出代价的。你怎么知道捷径是不是一条不归路呢?
# 链接
杭电Oj - 1001
http://acm.hdu.edu.cn/
【C】杭电Oj-1001题解
https://gitee.com/fangjiaxiaobai/leetCode.git
# 最后
希望与你一起遇见更好的自己