HDOJ(HDU) 2162 Add ‘em(求和)
来源:互联网 发布:电脑下载软件哪个好 编辑:程序博客网 时间:2024/06/03 07:37
Problem Description
Write a program to determine the summation of several sets of integers.
Input
The input file will consist of up to 250 sets of integers, where each set contains at most 100 integers and the integer values will be between –16000 and + 16000. Each set of numbers is started with the number of integers in the set, n. The next n input lines will each contain one integer of the set. You should stop processing when the size of the set, n, is<= 0.
Output
A single line of output should be generated for each set of integers. The line should have format shown below.
Sample Input
4
-1
3
1
1
2
19
17
5
-645
952
-1488
-5456
-9342
-1
Sample Output
Sum of #1 is 4
Sum of #2 is 36
Sum of #3 is -15979
简单题,就是求和。
import java.util.Scanner;public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=0; while(sc.hasNext()){ int n =sc.nextInt(); if(n==-1){ break; } long sum=0; for(int i=0;i<n;i++){ long a = sc.nextLong(); sum+=a; } System.out.println("Sum of #"+(++t)+" is "+sum); } }}
- HDOJ(HDU) 2162 Add ‘em(求和)
- hdu-2162-Add ‘em
- hdu 2162 Add ‘em
- hdu 2162 Add ‘em
- HDOJ 2162 Add ‘em(水题)
- JAVA hdu 2162 Add ‘em
- Add ‘em 2162
- hd 2162 Add ‘em
- HDOJ(HDU) 2156 分数矩阵(嗯、求和)
- HDOJ(HDU) 2304 Electrical Outlets(求和、、)
- 杭电acm 2162 Add ‘em
- HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)
- Add ‘em hdoj2162
- hdu2162 Add ‘em
- Hdu2162 Add ‘em
- 利用ADD横向求和
- 1407281202-hd-Add ‘em.cpp
- HDOJ-2015 偶数求和
- python模块
- image2lcd的使用
- Java强引用、软引用、弱引用和虚引用
- http_load使用
- Objective-C之run loop详解
- HDOJ(HDU) 2162 Add ‘em(求和)
- hdu1180诡异的楼梯(bfs)
- C++第五次实验-项目1:数组分离
- 给定一个字符串,找出其所有不重复的排列组合
- 第五届华中区程序设计邀请赛暨武汉大学第十四届校赛 现场赛 WHU oj Problem 1613 - Count in Sama’s triangle 扩展欧几里得
- 《程序员自我修养》第十章读书笔记
- 归并排序
- 蓄水池算法
- Asp.net相对路径连接Access数据库的方法