Electrical Outlets
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 9597   Accepted: 7186

Description

Roy has just moved into a new apartment. Well, actually the apartment itself is not very new, even dating back to the days before people had electricity in their houses. Because of this, Roy's
apartment has only one single wall outlet, so Roy can only power one of his electrical appliances at a time. 

Roy likes to watch TV as he works on his computer, and to listen to his HiFi system (on high volume) while he vacuums, so using just the single outlet is not an option. Actually, he wants to have all his appliances connected to a powered outlet, all the time.
The answer, of course, is power strips, and Roy has some old ones that he used in his old apartment. However, that apartment had many more wall outlets, so he is not sure whether his power strips will provide him with enough outlets now. 

Your task is to help Roy compute how many appliances he can provide with electricity, given a set of power strips. Note that without any power strips, Roy can power one single appliance through the wall outlet. Also, remember that a power strip has to be powered
itself to be of any use.

Input

Input will start with a single integer 1 <= N <= 20, indicating the number of test cases to follow. Then follow N lines, each describing a test case. Each test case starts with an integer 1 <= K <= 10, indicating the number of power strips in the test case.
Then follow, on the same line, K integers separated by single spaces, O1 O2 . . . OK, where 2 <= Oi <= 10, indicating the number of outlets in each power strip.

Output

Output one line per test case, with the maximum number of appliances that can be powered.

Sample Input

3
3 2 3 4
10 4 4 4 4 4 4 4 4 4 4
4 10 10 10 10

Sample Output

7
31
37

Source

你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

#include<stdio.h>
int main()
{
int t, a, sum, n, i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
sum = 1 - n;
for(i=0; i<n; i++)
{
scanf("%d",&a);
sum += a;
}
printf("%d\n",sum);
}
}

POJ 2636:Electrical Outlets的更多相关文章

  1. zoj 2807 Electrical Outlets

    Electrical Outlets Time Limit: 2 Seconds      Memory Limit: 65536 KB Roy has just moved into a new a ...

  2. HDOJ(HDU) 2304 Electrical Outlets(求和、、)

    Problem Description Roy has just moved into a new apartment. Well, actually the apartment itself is ...

  3. POJ 2636

    #include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("a ...

  4. POJ解题经验交流

    感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理.   题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...

  5. 算法之路 level 01 problem set

    2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...

  6. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  7. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  8. What is Cross Linux From Scratch?

    /**************************************************************************** * What is Cross Linux ...

  9. OJ题解记录计划

    容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2 ...

随机推荐

  1. 笔试算法题(15):-1到N中包含1的数字的个数 & 连续和为N的序列

    出题:输入一个整数N,求从1到N这N个整数的十进制表示中‘1’出现的次数: 分析: 从左向右处理string表示的数字:当前数字长度为n,判断最左边一位数字字符: 如果是0,则直接递归下一位: 如果是 ...

  2. 笔试算法题(11):Josephus环 & Fibonacci序列

    出题:Josephus Cycle,约瑟夫环问题.k个数字连成一个环,第一个数字为1.首先从1开始计数删除第m个数字:然后从上次被删除的数字的下一个数字开始计数,删除第m个数字:重复进行第二步直到只剩 ...

  3. 零基础入门学习Python(3)--小插曲之变量和字符串

    前言 小甲鱼说,在对前边的小游戏改善前,先了解下,Python中的变量与字符串. 主要内容 变量 变量名就像我们现实社会的名字,把一个值赋值给一个名字时,Ta会存储在内存中,称之为变量(variabl ...

  4. MapReduce架构与执行流程

    一.MapReduce是用于解决什么问题的? 每一种技术的出现都是用来解决实际问题的,否则必将是昙花一现,那么MapReduce是用来解决什么实际的业务呢? 首先来看一下MapReduce官方定义: ...

  5. vscode 解决符号无法识别的问题

    一开始浏览代码出现了下面这个问题, __attribute__ 标记为红色,符号无法识别,下面还出现了很多提示需要加 ), } 等符号,虽然编译没问题,但是看着红色标记和一堆提示真是要逼死强迫症. 既 ...

  6. Windows学习总结(11)——Windows批处理命令编写代码及小程序简介

    批处理(Batch)也称为批处理脚本.顾名思义,就是对某对象进行批量的处理.DOS批处理是基于DOS命令,用来自动地批量地执行DOS命令以实现特定操作的脚本.批处理是一种简化的脚本语言,它应用于DOS ...

  7. xcap发包工具的简单使用3(报文描述)

    之前详细介绍了如何构造以及发送报文,现在简单对报文描述一下 1.Ethernet MAC:填写报文目的mac和源mac地址 Vlan:支持单vlan,QinQ,如果有更多的vlan,请填写在“More ...

  8. node框架express里面静态文件中间件express.static,根据路径名查找文件

    - 是express框架下的一个方法,可以根据请求路径名查找某个文件下文件名字和路径名相同的文件 - 3.X里面有20多个中间件,但是在4.X里面 只保留了express.static - 语法 ex ...

  9. 安装K/3 Cloud过程中发现的两个新问题。

    卸载掉K/3 Cloud然后重装时出现下面的错误提示: 可能原因: 1.安装目录下的Setup.exe会检查操作系统版本.有些操作系统可能是被串改过注册信息,所以取不到版本信息(有些是因为盗版的原因) ...

  10. JSP内置对象和EL内置对象

    JSP共有九大内置对象: (1) HttpSession类的session对象作用:主要用于来分别保存每个用户信息,与请求关联的会话:         会话状态维持是Web应用开发者必须面对的问题. ...