http://acm.hdu.edu.cn/showproblem.php?pid=2162

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
 
代码:

#include <bits/stdc++.h>
using namespace std; int a[1111]; int main() {
int n, cnt = 0;
while(~scanf("%d", &n)) {
getchar();
if(n <= 0) break;
cnt ++;
int sum = 0;
for(int i = 1; i <= n; i ++) {
scanf("%d", &a[i]);
sum += a[i];
} printf("Sum of #%d is %d\n", cnt, sum); }
return 0;
}

  

HDU 2162 Add ‘em的更多相关文章

  1. HDOJ(HDU) 2162 Add ‘em(求和)

    Problem Description Write a program to determine the summation of several sets of integers. Input Th ...

  2. HDU 2162(注意初始化位置!)

    Add ‘em Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  3. HDU 6033 - Add More Zero | 2017 Multi-University Training Contest 1

    /* HDU 6033 - Add More Zero [ 简单公式 ] | 2017 Multi-University Training Contest 1 题意: 问 2^n-1 有几位 分析: ...

  4. 2017 Multi-University Training Contest - Team 1 1001&&HDU 6033 Add More Zero【签到题,数学,水】

    Add More Zero Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  5. HDU 6033 Add More Zero (数学)

    Description There is a youngster known for amateur propositions concerning several mathematical hard ...

  6. 2017ACM暑期多校联合训练 - Team 1 1001 HDU 6033 Add More Zero (数学)

    题目链接 Problem Description There is a youngster known for amateur propositions concerning several math ...

  7. hibernate之关联映射

    No.1 映射一对多双向关联关系: 当类与类之间建立了关联,就可以方便的从一个对象导航到另一个或另一组与它关联的对象. 步骤一: 注意:hibernate要求在持久化类中定义集合类属性时,必须把属性类 ...

  8. C# 小型资源管理器

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. 解决WebService 中泛型接口不能序列化问题

    本来要定义WebServices 方法返回一泛型接口集合IList,系统提示不能序列化泛型接口集合  1   [WebMethod]  2         public IList<Employ ...

随机推荐

  1. python 内置调试工具 pdb

    除了 pycharm 可以调试python外,python自带的内置工具pdb 也可以调试 python.其命令方式类似于 gdb. pdb 常用的调试命令见下表. 命令 解释 break 或 b 设 ...

  2. SQL学习笔记:函数

    SQL函数 AVG select AVG(col) AS avgvalue from tablename select col2 from tablename where col1>(selec ...

  3. Altera三速以太网IP核使用(下篇)--- 百兆网接口设计与使用

    MAC IP核的主要作用是:实现数据链路层协议,分为TX方向与RX方向,TX方向实现的是在原包文的前面加上7个55和1个D5,RX方向则相反.在使用这个 MAC IP核之前,首先确认下自己使用的网卡是 ...

  4. 纪中OJ 2019.02.15【NOIP提高组】模拟 B 组 梦回三国 比赛题解(第一个)

    声明 旁边的同学小 H(胡)对我说: “哟,比赛拿了 140,强!要知道,如果哥第三题 AC 了,哥就 230 了,你个废柴!!!(比赛实际分数 130 额呵)” 顿时,千万草泥马从我心中奔腾而过:你 ...

  5. 20155217 2016-2017-2《java程序设计》第一周学习总结

    20155217 2016-2017-2<java程序设计>第一周学习总结 浏览教材,根据自己的理解每章提出一个问题 java平台和java编程语言的区别? 怎样使用IDE来管理原始码与位 ...

  6. 20155302 2016-2017-2 《Java程序设计》第3周学习总结

    20155302 2016-2017-2 <Java程序设计>第3周学习总结 教材学习内容总结 两个基本的标准类:java.util.Scanner与java.math.BigDecima ...

  7. #20155319 2016-2017-2 《Java程序设计》第3周学习总结

    20155319 2016-2017-2 <Java程序设计>第3周学习总结 教材学习内容总结 第三周的学习量还是很大的,需要学习的内容更难了而且 量也变多了,所以投入了更多的时间到Jav ...

  8. PhoneGap3.2安装步骤

    1.首选安装好JDK.Android SDK.Ant 配置如下:        系统环境变量        ANDROID_HOME Value: C:\Development\adt-bundle\ ...

  9. Nginx入门篇(六)之反向代理和负载均衡

    一.Nginx负载均衡集群 介绍 负载均衡(Load Balance)集群提供了一种行之有效的办法,来扩展网络设备和服务器负载.带宽和吞吐量,同时加强了网络数据处理能力,提供了网络的灵活性和可用性. ...

  10. sqoop 数据迁移

    sqoop 数据迁移 1 概述 sqoop是apache旗下一款“Hadoop和关系数据库服务器之间传送数据”的工具. 导入数据:MySQL,Oracle导入数据到Hadoop的HDFS.HIVE.H ...