hdu 1001 解析
来源:互联网 发布:win7系统无法安装软件 编辑:程序博客网 时间:2024/06/14 17:48
Sum Problem
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 417111 Accepted Submission(s): 105118
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.
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
1100
Sample Output
15050
题意:多组测试数据,输入一个数n,计算1+2+……n。
思路:用for循环来解决。
注意点:每一组数据之间有一个空行。
代码如下:
#include<iostream>#include<cstdio>using namespace std;int main(){ int a,b; while(cin>>a) { int sum=0; for(int i=1;i<=a;i++) sum+=i; cout<<sum<<endl<<endl; } return 0;}
0 0
- hdu 1001 解析
- hdu 1088 HTML解析
- HDU动态规划解析
- hdu 1000 解析
- hdu 1002 解析
- HDU 1166 敌兵布阵 解析
- HDU 4668 Finding string (解析字符串 + KMP)
- hdu 1241 Oil Deposits思路解析
- HDU 4911 归并排序题目解析
- hdu 1001
- HDU 1001
- hdu 1001
- hdu 1001
- HDU 1001
- HDU 1001
- hdu 1001
- HDU 1001
- HDU 1001
- Android消息推送(二)--基于MQTT协议实现的推送功能
- scala进阶7-类型约束
- HTML5从入门到精通
- C++对象的内存分析(6)
- ubuntu移植crypto++到Android平台
- hdu 1001 解析
- UFLDL sparse coding ICA RICA[待更]
- ubuntu下搭建android开发环境(三)ubuntu安装搜狗输入法(by 星空武哥)
- 6410 linux DM9000收包机制
- 线程的几个主要概念
- ubuntu移植libcurl到Android平台
- Android开发-Looper类介绍
- 网易内推笔试题--数字游戏
- AsyncTask对照 Thread加Handler