杭电2304
来源:互联网 发布:加载寄售物品数据库 编辑:程序博客网 时间:2024/06/10 19:22
Electrical Outlets
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2144 Accepted Submission(s): 1892
Problem 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.
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
33 2 3 410 4 4 4 4 4 4 4 4 4 44 10 10 10 10
Sample Output
73137
题目大意:
先输入有多少组,每组开头输入插板的数量,后面输入每个插板的插孔数。求当只有一个电源孔,问最后有多少插孔可用。
#include <iostream>using namespace std;int main(){int i,m,n,x,sum;cin>>m;while (m--){cin>>n;sum=0;for(i=0;i<n-1;i++) {cin>>x;sum+=x-1;}cin>>x;sum+=x;cout<<sum<<endl;}return 0;}
0 0
- 杭电2304
- 杭电2304
- 杭电 2304
- 杭电
- 杭电
- 杭电
- HDU--杭电--2304--Electrical Outlets--水题
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- 杭电ACM1061Rightmost Digit
- 杭电2099 7.11
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电ACM1466
- 杭电ACM1003
- 杭电ACM1225
- 杭电ACM2023
- 杭电ACM2602
- 总结 XSS 与 CSRF 两种跨站攻击
- Python GUI 09----Spinbox
- c++面试题
- Visual Studio 2010启动IIS6.0调试程序,报无法调试异常
- Spring中如何配置Hibernate事务
- 杭电2304
- Integer与int比较
- TEXT() 宏,以宏UNCODE为其开关,代表windows 编程风格;_T() 宏,以宏_UNCODE为其开关,代表C/C++编程风格
- 稳、准、狠:京东开放平台的“速度与激情”
- 程序员为什么喜欢夜间工作?
- 马云鼓动年轻人2015创业是存私心的?
- 第6周项目6复数模板类(友元函数)
- 如何做seo优化
- 通过重写ViewGroup学习onMeasure()和onLayout()方法