求和问题 Sum Problem
来源:互联网 发布:win7运行xp软件 编辑:程序博客网 时间:2024/06/04 18:00
Sum Problem
题目—from hdoj
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
100Sample Output
1
5050Author DOOM III
分析
程序
import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextInt()) { int a = sc.nextInt(); int sum = 0; for (int i = 1; i <= a; i++) sum += i; System.out.println(sum); System.out.println(); } }}
0 0
- 求和问题 Sum Problem
- Sum problem 求和问题
- HDOJ 2058 The sum problem(数学求和问题)
- hdu1001 Sum Problem (等差数列求和)
- hdoj 2058 The sum problem 【等差数列求和】
- 杭电OJ-1001-(Sum Problem大整数求和问题)
- The sum problem——关于连续子数列的求和问题
- HDOJ sum problem 问题
- Maximum Subsequence Sum Problem最大顺序子序列求和
- HDOJ-2058 The sum problem(等差数列求和)
- (Java实现) HDOJ 2058 The sum problem 高斯求和
- HDU 2058 The sum problem (等差数列求和变形)
- acmcoder1001:Sum Problem细节问题
- 求和 sum
- sum求和
- LeetCode 求和问题总结(2sum,3sum,ksum)
- 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
- 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
- 现实世界里的 SOA
- Rikka with Tree
- web简单基础,它是什么?
- Markdown中Latex 数学公式基本语法
- 【memcache缓存专题(2)】memcache安装与命令行使用
- 求和问题 Sum Problem
- String,StringBuffer,StringBuilder区别
- 求MySQL先按大于等于当前时间升序排序,再按小于当前时间降序排序
- fragment里面new一个Dialog报错
- 【memcache缓存专题(3)】PHP-memcache扩展的安装以及使用
- Android之Canvas详解
- ios UINavigationController右滑跨级返回问题
- ObjectMapper读取转义字符
- Servlet、Filter、Listener深入理解