A + B Problem (4)

时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte
总提交:2496            测试通过:1249

描述

Calculate the sum of some integers.

输入

The input will consist of multiple test cases. Each test case consist of an integer N and then N integers following in the same line,separated by a space. A line starting with 0 terminates the input and this line is not to be processed.

输出

For test case, you should output their sum in one line, and with one line of output for each line in input. After each test case output, you should output one blank line.

样例输入

4 1 2 3 4
5 1 2 3 4 5
0

样例输出

10

15

题目来源

HDUOJ

#include<iostream>
#include<vector>
using namespace std;
int main(){
int i,a,b;
vector<int> ivec;
int sum=;
while(cin>>a)
{
if(a==)
break;
for(i=;i<a;i++)
{
cin>>b;
sum+=b;
}
ivec.push_back(sum);
sum=;
}
for(i=;i<ivec.size();i++)
cout<<ivec[i]<<endl<<endl;
return ;
}

ACM——A + B Problem (4)的更多相关文章

  1. ACM - a + b Problem

    前几天看了ACM的第一题,映入眼帘的是一个“简单”的题目: 输入两个数,a,b 输出他们的和. 本着,此乃ACM的原则,便有了如下的思考: ACM的题目肯定很难,a+b,怎么可能直接printf,不行 ...

  2. ACM: A Simple Problem with Integers 解题报告-线段树

    A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%lld & %l ...

  3. ACM——A + B Problem (3)

    Home Problems 1086 A + B Problem (3) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2317 ...

  4. ACM——A + B Problem (2)

    A + B Problem (2) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:2600            测试通过:137 ...

  5. ACM——A + B Problem (1)

    A + B Problem (1) 时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte总提交:5907            测试通过:151 ...

  6. 2013年 ACM 有为杯 Problem I (DAG)

    有为杯  Problem I DAG  有向无环图 A direct acylic graph(DAG),is a directed graph with no directed cycles . T ...

  7. ACM程序设计选修课——Problem E:(ds:图)公路村村通(优先队列或sort+克鲁斯卡尔+并查集优化)

    畅通工程 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  8. ACM程序设计选修课——Problem D: (ds:树)合并果子(最优二叉树赫夫曼算法)

    Problem D: (ds:树)合并果子 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 80  Solved: 4 [Submit][Status][ ...

  9. 【ACM】hdu_zs3_1008_Train Problem I_201308100835

    Train Problem I Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)Tota ...

随机推荐

  1. 使用PowerDesigner建立数据库模型

    转自:http://www.cnblogs.com/tonyepaper/archive/2008/02/12/1067260.html 1.       打开PowerDesigner,点击File ...

  2. zzzz

    using System; using System.Collections.Generic; using System.Diagnostics; using System.Management; u ...

  3. NET中的引用类型和值类型 zt

    .NET中的类型分为值类型和引用类型,他们在内存布局,分配,相等性,赋值,存储以及一些其他的特性上有很多不同,这些不同将会直接影响到我们应用程序 的效率.本文视图对.NET 基础类型中的值类型和引用类 ...

  4. POJ 1773 Parity game 带权并查集

    分析:带权并查集,就是维护一堆关系 然后就是带权并查集的三步 1:首先确定权值数组,sum[i]代表父节点到子节点之间的1的个数(当然路径压缩后代表到根节点的个数) 1代表是奇数个,0代表偶数个 2: ...

  5. js获取本月第几周和本年第几周

    var getMonthWeek = function (a, b, c) { /* a = d = 当前日期 b = 6 - w = 当前周的还有几天过完(不算今天) a + b 的和在除以7 就是 ...

  6. 用java api读取HDFS文件

    import java.io.IOException; import java.io.InputStream; import java.security.PrivilegedExceptionActi ...

  7. [九度OJ]1011.最大连续子序列

    原题链接:http://ac.jobdu.com/problem.php?pid=1011 题目描述:     给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ N ...

  8. Spring-demo1(初学者的尝试,2015.03.19)

    项目结构: 源代码如下: package com.bean; public interface Person { public void Speak(); } package com.bean; pu ...

  9. 代码修改mysql字符

    为了不再显示的时候乱码,要修改数据库默认编码.以下以GBK编码页面为例进行说明: 1.修改MYSQL的配置文件:my.ini里面修改default-character-set=gbk2.代码运行时修改 ...

  10. 大型网站应用中MySQL的架构演变史

    没有什么东西是一成不变的,包含我们的理想和生活!MySQL作为一个免费的开源的关系型数据库,深受大家喜爱,从最初的无人问津到当下的去IOE,都体现出了MySQL举足轻重的作用.今天我们就从淘宝的发展来 ...