HDU 1001 Sum Problem
来源:互联网 发布:软件功能需求说明书 编辑:程序博客网 时间:2024/05/16 10:25
这是一道带着坑的水题。
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
/************************************************************************* > File Name: 1001_Sum_Problem.c > Author:lucifer lawliet > Mail:hnzhrh@foxmail.com > Created Time: 2016年06月06日 星期一 15时07分22秒 ************************************************************************/#include<stdio.h>int main(){ int n; while(scanf("%d",&n)!=EOF) { if(n&1) printf("%d\n\n",(1+n)/2*n); else printf("%d\n\n",n/2*(n+1)); }}
0 0
- HDU 1001 Sum Problem
- HDU--1001--Sum Problem
- hdu 1001 Sum Problem
- hdu 1001 Sum Problem
- hdu 1001 Sum Problem
- hdu 1001 sum problem
- HDU 1001 Sum Problem
- hdu 1001 Sum Problem
- HDU 1001 Sum Problem
- hdu 1001 Sum Problem
- hdu 1001 sum problem
- HDU 1001 sum problem
- Sum Problem-hdu-1001
- HDu 1001 Sum Problem
- hdu 1001 sum problem
- HDU 1001 Sum Problem
- HDU 1001 Sum Problem
- hdu 1001 Sum Problem
- 简单选择排序的代码实现与思考
- NFS挂载时出现"mount.nfs: access denied by server while mounting "的解决方法
- Android SDK与API的对应关系
- 坐拥云端,看透你的"上帝"心思!
- Spiral Matrix(medium)
- HDU 1001 Sum Problem
- hadoop fsck
- RXAndroid源码分析(二) 简单的例子
- 112. Path Sum [easy] (Python)
- Eclipse快捷键
- 啊啊啊
- Linux下64 位 预编译 的 go 1.6.2 安装
- 数据结构—图的存储—邻接表和邻接矩阵
- ffmpegturtor06.c做了修改,使用sdl2.0