杭电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.
 

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
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 六角头冲得不标准怎么办 滚丝杆烫手怎么办怎样能不烫手 带滚花的杆子里面脏怎么办 田螺和玉米吃了怎么办 lv包包螺丝掉了怎么办 螺狮那一段吃了怎么办 吃了不熟的田螺怎么办 包上的螺丝掉了怎么办 工厂打螺丝手疼怎么办 打螺丝打到手痛怎么办 欧曼gtl不烧尿素怎么办 放油螺丝滑牙怎么办 蝴蝶刀螺丝松了怎么办 婴儿车铆钉松了怎么办 扇子上的铆钉松怎么办 锅的把手松了怎么办 奶锅把手松了怎么办 锅的手柄烧坏了怎么办 鞋子上的铆钉生锈了怎么办 包包上的铆钉生锈了怎么办 凉鞋的铆钉生锈了怎么办 扇子的铆钉坏了怎么办 包包的铆钉坏了怎么办 汽车半轴螺丝母拧不动怎么办? 卫衣袖子短了怎么办 u型导轨蚊帐下垂怎么办 100的水管螺纹出漏水怎么办 吊顶螺丝没有防锈处理怎么办 膨胀螺丝洞松了怎么办 膨胀螺丝眼大了怎么办 墙上螺丝孔大了怎么办 膨胀螺丝孔深了怎么办 克霉膨胀栓的线怎么办 摩托车排气管螺丝断了怎么办 汽车轮胎螺丝卸不下来怎么办 内六角螺丝卸不下来怎么办 洗衣机六角螺丝卸不动怎么办 黄油嘴打不进去怎么办 螺杆冷水机氟系统有空气怎么办 脚踏式加油枪皮碗不下去怎么办? 自攻螺丝滑丝怎么办?