hdu 1001
2016-07-09 22:04
316 查看
Sum Problem
[b]Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 412274 Accepted Submission(s): 103727
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 a,sum; while(scanf("%d",&a)!=EOF){ sum=0; for(int i=1;i<=a;i++) sum+=i; printf("%d\n\n",sum); } return 0; }
[/b]
相关文章推荐
- 309. Best Time to Buy and Sell Stock with Cooldown
- 繁简体(GB<=>Big5)字符串互转的JAVA方式实现
- [华为OJ] 字符串加解密
- HTML5基础知识
- 获取Android Studio的SHA1
- 复数类的设计及加减法的实现(Complex Numbers)
- Codeforces Round #358 (Div. 2) D. Alyona and Strings(DP)
- hibernate中Query的list和iterator区别(续)
- Windows进程通信 -- 共享内存
- 华为机试--最高分是多少
- Solr/SolrCloud SolrConfigHandler详解
- 华为机试题【11】-报数删除人
- iOS多线程技术-上
- 华为机试题【11】-报数删除人
- 华为机试题【11】-报数删除人
- 华为机试题【11】-报数删除人
- 1、linux软件包管理
- Word Search
- 【自定义View系列】04--谈谈事件分发
- MFC标题和文字的修改