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. 51nod 1057 n的阶乘 (压位优化)

    题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1057&judgeId=605203 使用压位进行优化, ...

  2. python 3 廖雪峰博客笔记(一) python特性

    python 是一种解释性语言,代码在执行时会一行一行翻译成CPU能理解的机器语言. python 的特点是简单优雅. python 的优点是 代码优雅 基础代码库丰富,包括网络.文件.GUI.数据库 ...

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

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

  4. centos下安装redis(记录其中踩坑的过程)

    一.先下载到redis-3.0.4.tar.gz包(本文以3.0.4版本为例) 我将这个包放在/opt目录下,在/opt下并解压这个包 tar -zxvf redis-.tar.gz 然后进入redi ...

  5. assert.ifError()函数详解

    assert.ifError(value) 如果 value 为真值时,抛出 value.当测试在回调函数里的参数 error 时非常有用. const assert = require('asser ...

  6. 【面试题】LRU算法及编码实现LRU策略缓存

    概念 LRU(least recently used)就是将最近不被访问的数据给淘汰掉,LRU基于一种假设:认为最近使用过的数据将来被使用的概率也大,最近没有被访问的数据将来被使用的概率比较低. 原理 ...

  7. HDU-1163Eddy's digital Roots,九余定理的另一种写法!

    下午做了NYOJ-424Eddy's digital Roots后才正式接触了九余定理,不过这题可不是用的九余定理做的.网上的博客千篇一律,所以本篇就不发篇幅过多介绍九余定理了: 但还是要知道什么是九 ...

  8. hdu 3691最小割将一个图分成两部分

    转载地址:http://blog.csdn.net/xdu_truth/article/details/8104721 题意:题给出一个无向图和一个源点,让你求从这个点出发到某个点最大流的最小值.由最 ...

  9. [转]如何阅读android framework源码

    但如果想深入的了解Android系统, 那么可以看下我的一些简单的总结. 知识 Java Java是AOSP的主要语言之一. 没得说, 必需熟练掌握. 熟练的Android App开发 Linux A ...

  10. 执行循环任务new Timer().schedule(new TimerTask(){},0,1000);

    package com.pingyijinren.test; import android.support.v7.app.AppCompatActivity; import android.os.Bu ...