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. Leecode刷题之旅-C语言/python-387 字符串中的第一个唯一字符

    /* * @lc app=leetcode.cn id=387 lang=c * * [387] 字符串中的第一个唯一字符 * * https://leetcode-cn.com/problems/f ...

  2. poj 2739 Sum of Consecutive Prime Numbers 尺取法

    Time Limit: 1000MS   Memory Limit: 65536K Description Some positive integers can be represented by a ...

  3. HIVE-分桶表的详解和创建实例

    我们学习一下分桶表,其实分区和分桶这两个概念对于初学者来说是比较难理解的.但对于理解了的人来说,发现又是如此简单. 我们先建立一个分桶表,并尝试直接上传一个数据 buckets row format ...

  4. apt-get 0%

    错误如下:      www.2cto.com   使用apt-get命令安装软件时出现“0%[正在等待报头]“的提示且无法继续安装,一般出现此问题是因为安装过程中Ctrl+C强行中断或其它原因导致上 ...

  5. mfc通过MapWinGIS控件读取shp文件(不通过#import实现)

    1.首先注册MapWinGIS ActiveX组件, 引入MapWinGIS.ocx产生的MapWinGIS_i.h和MapWinGIS_i.c文件,利用CoCreateInstance函数来调用 演 ...

  6. CF 1025 D. Recovering BST

    D. Recovering BST http://codeforces.com/contest/1025/problem/D 题意: 给出一个连续上升的序列a,两个点之间有边满足gcd(ai ,aj) ...

  7. Walle代码发布

    一.概述 Walle 一个web部署系统工具,配置简单.功能完善.界面流畅.开箱即用!支持git.svn版本管理,支持各种web代码发布,PHP,Python,JAVA等代码的发布.回滚,可以通过we ...

  8. AWVS11提取规则文件

    在这里给大家分享一个获取AWVS规则文件的思路.  目前我提取的是17年4月份的扫描规则.   后面如果规则更新,可以自行提取 官网:   https://www.acunetix.com/vulne ...

  9. python全栈开发-前方高能-函数

    python_day_9 一.今日主要内容 函数: 函数:对功能的封装 语法: def 函数名(形参): 函数体 函数名(实参) 函数名:命名规则和变量一样 函数的返回值: return, 函数执行完 ...

  10. uvaoj 156Ananagrams(map和vector组合使用)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...