博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2636 Electrical Outlets(我的水题之路——水,电器接头)
阅读量:4069 次
发布时间:2019-05-25

本文共 2299 字,大约阅读时间需要 7 分钟。

Electrical Outlets
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 7124   Accepted: 5413

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

Source

题意有点难懂,一个屋子里只有一个电源接口,现在Roy有N个外接插座,分别可以接Oi个插头,问,使用了这些插座之后,Roy一共可以外接多少个电器。
外接插座要使用也必须占用一个插座,将Oi累加,然后减去(外接插座数量N - 1)。
代码(1AC):
#include 
#include
int main(void){ int casenum, ii; int sum, tmp; int n, i; scanf("%d", &casenum); for (ii = 0; ii < casenum; ii++){ sum = 0; scanf("%d", &n); for (i = 0; i < n ; i++){ scanf("%d", &tmp); sum += tmp; } sum -= (n - 1); printf("%d\n", sum); } return 0;}

转载地址:http://rooji.baihongyu.com/

你可能感兴趣的文章
《软件过程管理》 第九章 软件过程的评估和改进
查看>>
《软件过程管理》 第八章 软件过程集成管理
查看>>
分治法 动态规划法 贪心法 回溯法 小结
查看>>
《软件体系结构》 练习题
查看>>
《数据库系统概论》 第一章 绪论
查看>>
《数据库系统概论》 第二章 关系数据库
查看>>
《数据库系统概论》 第三章 关系数据库标准语言SQL
查看>>
SQL语句(二)查询语句
查看>>
SQL语句(六) 自主存取控制
查看>>
《计算机网络》第五章 运输层 ——TCP和UDP 可靠传输原理 TCP流量控制 拥塞控制 连接管理
查看>>
堆排序完整版,含注释
查看>>
二叉树深度优先遍历和广度优先遍历
查看>>
生产者消费者模型,循环队列实现
查看>>
PostgreSQL代码分析,查询优化部分,process_duplicate_ors
查看>>
PostgreSQL代码分析,查询优化部分,canonicalize_qual
查看>>
PostgreSQL代码分析,查询优化部分,pull_ands()和pull_ors()
查看>>
ORACLE权限管理调研笔记
查看>>
移进规约冲突一例
查看>>
IA32时钟周期的一些内容
查看>>
SM2椭圆曲线公钥密码算法
查看>>