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. 编写DVWA暴力破解High级别的Python脚本

    1. 过程(不查看源代码) 使用burpsuite或者owasp zap抓取数据包,可以看出页面执行过程如下: 首先获取上一次请求的token,然后sleep几秒,最后使用get方法提交验证. 2. ...

  2. 用k8s构建生产环境下应用服务

    1.生成镜像 见https://www.cnblogs.com/mushou/p/9713741.html,把测试成熟的应用添加到tomcat镜像生成新的镜像,用ansible部署到集群的几点服务器中 ...

  3. HxUtils: 批量转换换行符,print2to3

    在 windows 和 linux 系统,换行符有时需要转换,其代码文件 HxUntils.py 如下: ''' HxUtils.py 2018 by x01 ''' import os, sys d ...

  4. 【 C 】高级字符串查找之 strspn 和 strcspn 的思考

    我的CSDN博客 strspn 这个库函数是真的很难理解,看了很多中文描述,反正都是不知所云,给出一系列的例子,结果也是让我瞠目结舌,荒唐.荒谬.荒诞! 特此记录理解过程,最后竟然是百度百科让我明白了 ...

  5. leetcode记录-字符串转整数

    实现 atoi,将字符串转为整数. 该函数首先根据需要丢弃任意多的空格字符,直到找到第一个非空格字符为止.如果第一个非空字符是正号或负号,选取该符号,并将其与后面尽可能多的连续的数字组合起来,这部分字 ...

  6. 梯度下降、随机梯度下降、方差减小的梯度下降(matlab实现)

    梯度下降代码: function [ theta, J_history ] = GradinentDecent( X, y, theta, alpha, num_iter ) m = length(y ...

  7. c#获取已安装的所有NET版本

    /// <summary> /// 获取已安装的所有NET版本 /// </summary> /// <returns></returns> publi ...

  8. 【转载】图说C++对象模型:对象内存布局详解

    原文: 图说C++对象模型:对象内存布局详解 正文 回到顶部 0.前言 文章较长,而且内容相对来说比较枯燥,希望对C++对象的内存布局.虚表指针.虚基类指针等有深入了解的朋友可以慢慢看.本文的结论都在 ...

  9. Redis实现之客户端

    客户端 Redis服务器是典型的一对多服务器程序:一个服务器可以与多个客户端建立网络连接,每个客户端可以向服务器发送命令请求,而服务器则接收并处理客户端发送的命令请求,并向客户端返回命令回复.通过使用 ...

  10. bzoj4998 星球联盟

    bzoj4998 星球联盟 原题链接 题解 先按照输入顺序建一棵树(森林),然后用一个并查集维护联盟的关系,对于不是树上的边\(a-b\),就把\(a-lca(a,b),b-lca(a,b)\)全部合 ...