1072 -- Sum Problem
来源:互联网 发布:域名劫持转发教程 编辑:程序博客网 时间:2024/06/06 06:54
Sum Problem
Time Limit:1000MS Memory Limit:65536K
Total Submit:504 Accepted:268
Description
Hey, welcome to ahstu oj.
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. You may assume the result will be in the range of 32-bit signed integer.
Sample Input
1100
Sample Output
15050
Source
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AK1072 { class Program { static void Main(string[] args) { string sb; while ((sb = Console.ReadLine()) != null) { long n = long.Parse(sb); long sum = (1 + n) * n / 2; Console.WriteLine(sum); } } } }
0 0
- 1072 -- Sum Problem
- Sum Problem
- Sum Problem
- sum problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- sum problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- Sum Problem
- 1070 -- A+B(7)
- Windows风格的Loading动画Android实现(3)
- 【链表】逆序输出
- 1071 -- A+B(8)
- CSU 1631 Facility Locations
- 1072 -- Sum Problem
- 2015-0828-osg学习历程3
- linux驱动调试技术
- 空字符 空格字符(字符) 空字符串 NULL的区别
- 原型模式
- 1073 -- Let the Balloon Rise
- 与图灵机器人聊天
- 彻底解决mysql数据乱码问题
- Qt 学习之路 2(3):Hello, world! 笔记