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. 【project】十次方-01

    前言 项目介绍 系统分为3大部分:微服务.网站前台.网站管理后台:功能模块分为:问答.招聘.交友中心等 该项目融合了Docker容器化部署.第三方登陆.SpringBoot.SpringCloud.S ...

  2. Oracle 数据库实例启动关闭过程

    Oracle数据库实例的启动,严格来说应该是实例的启动,数据库仅仅是在实例启动后进行装载.Oracle数据启动的过程被划分为 几个不同的步骤,在不同的启动过程中,我们可以对其实现不同的操作,系统修复等 ...

  3. Nginx出现403 forbidden (13: Permission denied)报错的四种原因

    一.由于php-fpm启动用户和nginx工作用户不一致所致 php-fpm启动用户配置位置 nginx工作用户配置位置 二.不存在在文件,可能是文件路径有误,可以查看nginx错误日志来判断 三.缺 ...

  4. LeetCode(61) Rotate List

    题目 Given a list, rotate the list to the right by k places, where k is non-negative. For example: Giv ...

  5. 【HDU 2196】 Computer (树形DP)

    [HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...

  6. CPLD和FPGA中不同电压的JTAG电路设计注意事项

    在初次的cpld电路设计的时候,遇到了这样的一个问题,整个系统是3.3V的系统,选用的cpld是XC9536-10VQ44C,芯片供电电压5V.他的io可以配置成3.3V和5V两种形式,因此,选用的时 ...

  7. caca需要用到x11作为图形输出

    编译错误:no output drivers were selected!. yum -y install xcb-proto yum -y install libxcb-devel.x86_64 l ...

  8. Django开发:(3.2)ORM:多表操作

    表关系总结: 一对多:在多的表中建立关联字段 多对多:创建第三张表(关联表):id 和 两个关联字段 一对一:在两张表中的任意一张表中建立关联字段(关联字段一定要加 unique 约束) 子查询:一次 ...

  9. 【BZOJ4710】分特产(容斥原理,组合计数)

    题意:有m种特产,第i种有a[i]个 有n个同学分特产,要求: 1.恰好分完 2.每个人至少要分到一个 求方案数模10^9+7 n,m,a[i]<=1000 思路:WYZ作业 首先考虑对于每一种 ...

  10. Linux下汇编语言学习笔记46 ---

    这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...