1001
2015-07-26 11:12
441 查看
Sum Problem
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
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<stdio.h> int main(){ int i, n, b = 0, s = 0; while(scanf("%d", &n) != EOF){ s = 0; for(i = 1; i <= n; i++){ s += i; } printf("%d\n\n", s); //看清题目中的样例输出之间有空格; } return 0; }
学习笔记:
Accepted (AC) 说明答案对了
Wrong Answer (WA) 说明错了
Time Limit Exceeded (TLE) 超时
Memory Limit Exceeded (MLE) 超内存
Compilation Error (CE) 编译错误
Presentation Error (PE) 格式错误 一般是空格和换行的问题
相关文章推荐
- 《ASP.NET》数据绑定—DataList实践篇
- NYOJ 865 解题报告
- python-eggs异常解决方法
- hdu 5310 Souvenir
- poj 2031 Building a Space Station
- JavaWeb学习笔记:Tomcat
- 虚基类
- 使用 C# 开发智能手机软件:推箱子(三)
- iOS中的类、属性的创建、使用流程
- compass使用的步骤
- 妆容之眼部
- 【分割圆】Uva 10213 - How Many Pieces of Land ?
- 类似淘宝产品预览的快速实现(jquery)
- uvalive(NIM博弈)
- 传感器获取旋转矩阵R,机身坐标系和世界坐标系的映射remapR,获得旋转角度 orientationValues;
- windows下FileZilla使用sftp(SSH-2)
- [Leetcode] Binary Tree Zigzag Level Order Traversal
- [leetcode 80, Medium] Remove Duplicates from Sorted Array II
- 设计模式_状态模式
- 编写spring配置文件时,不能出现帮助信息