POJ 2636: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'sapartment 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
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
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的更多相关文章
- zoj 2807 Electrical Outlets
Electrical Outlets Time Limit: 2 Seconds Memory Limit: 65536 KB Roy has just moved into a new a ...
- HDOJ(HDU) 2304 Electrical Outlets(求和、、)
Problem Description Roy has just moved into a new apartment. Well, actually the apartment itself is ...
- POJ 2636
#include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("a ...
- POJ解题经验交流
感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理. 题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...
- 算法之路 level 01 problem set
2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- 杭电ACM分类
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
- What is Cross Linux From Scratch?
/**************************************************************************** * What is Cross Linux ...
- OJ题解记录计划
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001 A+B Problem First AC: 2 ...
随机推荐
- 笔试算法题(56):快速排序实现之非递归实现,最小k值选择(non-recursive version, Minimal Kth Selection of Quick Sort)
议题:快速排序实现之五(非递归实现,短序列优先处理,减少递归栈大小) 分析: 算法原理:此算法实现适用于系统栈空间不足够快速排序递归调用的需求,从而使用非递归实现快速排序算法:使用显示下推栈存储快速排 ...
- 笔记——collections模块
collections模块 collections模块在内置数据类型(dict.list.set.tuple)的基础上,还提供了几个额外的数据类型:ChainMap.Counter.deque.def ...
- Orcad中较好的习惯背景
设置背景,能让眼睛不那么疲劳,尤其是白色背景,有的时候很耀眼,看的时间长了,眼疼. 因此萌生出更换背景的想法: Option->Preference中 第一列的Prin中"Alias& ...
- 节点回来shard仍然delayed原因
1:es2 fetch shard data时,存在节点刚加入集群,还没有收到cluster metadata的情况.此时,节点因为没有该索引,返回的sharddata为empty,主节点缓存了该sh ...
- JQuery常用的案例
1.给导航栏添加鼠标移上去的时候变换背景颜色的方法. $(function () { $(".nav li").mouseover(function () { $(this).cs ...
- Hadoop入坑记
Hadoop入坑记 按照官方给的伪分布式配置 etc/hadoop/core-site.xml: <configuration> <property> <name> ...
- Leetcode 179.最大数
最大数 给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数. 示例 1: 输入: [10,2] 输出: 210 示例 2: 输入: [3,30,34,5,9] 输出: 9534330 impo ...
- 《C语言程序设计(第四版)》阅读心得(三)
第八章 指针 1.一个变量的地址称为该变量的指针 一个专门用来存放另一变量的地址(即指针),称它为指针变量.指针变量的值是指针(即地址) 如上图2000是变量的指针,pointer是指针变量, 赋值 ...
- [JLOI2008]提示问题
题目描述 最近在JLOI网上的一个流行游戏中,选手要回答很难的问题.假如在规定时间内不能回答,系统将给出1个提示,之后再依次给出第2,3个提示.出现在答案中的是字母和下列字符: '.',',',':' ...
- ubuntu14.04 配置网络
ubuntu14.04 配置网络的练习 本文参考的资料: https://blog.csdn.net/liu782726344/article/details/52912797. 感谢作者的分享! 打 ...