河南省程序设计大赛历年真题(8)

2019-09-01 23:00

对于每一行测试数据,输出占一行,仅一个整数S, 表示作战安排的最大战斗力。 【 样 例 】

标准输入 2 5 4

标准输出 6 4 【 T3 】

试 制 品

ZZ大学的Dr.Kong最近发现实验室的很多试制品都已经用完。由于项目经费有限,为了节省,Dr.Kong决定利用实验室现有的试制品来生成所缺的试制品。为此,Dr.Kong连续几天通宵达旦整理出一份研究资料并让研究生Bill去实验并统计能产生多少种所缺的试制品。

Bill从头到尾翻完所有的资料,发现资料上写满了一大堆的化学方程式,上面除了大小写英文字母、数字、加号、等号外,再也没有其他的符号了。其中,每个方程式都是

A1+A2+??+Ap=B1+B2+??+Bq的形式, 表示试制品A1,A2,??和Ap反应,生成了试制品B1,B2,??,Bq。其中Ai和Bj都是一种单质或化合物的化学式(长度不超过10个字符),1≤

p,q ≤ 20 。每个方程式的总长不超过100个字符。有些试制品的化学式可能在现代社会的化学元素周期表里找不到,这是由于化学反应过程中可能又有物理反应导致的结果。

Bill头疼了,从哪个实验开始呢?你能帮助他吗?

【标准输入】

第一行: N 表示Dr.Kong写的化学方程式个数 (1≤ N ≤ 400) 接下来有N行, 每一行是一个方程式。

再接下来的一行:M 表示已有多少种试制品。 (1≤ M ≤500) 接下来有M行,每一行是已有的一种试制品的化学式。

【标准输出】

第一行包含一个数T,表示可以产生多少种所缺的试制品。 在接下来的T行中,按ASCII码升序输出产生的试制品的化学式。

【 样 例 】

标准输入 标准输出 4 H2O+Na=NaOH+H2 Cl2+H2=HCl Fe+O2=Fe3O4 NaOH+HCl=H2O+NaCl 3 H2O Na Cl2 4 H2 HCl NaCl NaOH 【 T4 】

遥 控 器

Dr.Kong 有一台高级电视机,这台电视机可以接受100个频道(从0到99编号)。电视的配套遥控器有13个按钮:

1 2 3 ↑ 4 5 6 ↓ 7 8 9 — 0

当按\↑\键时,当前频道编号会增加1(如果当前为99频道,则会切换到0频道)。如果按\↓\键,当前频道编号会减小1(如果当前为0频道,则会切换到99频道)。当要切换到0~9频道时,可以直接在遥控器上按相应的键。当要切换到10~99频道时,可以先按\—\键,然后按2个与频道编号相对应的数字键(即先按与频道编号的十位数字相对应的键,然后按与个位数字相对应的键)。

由于遥控器长时间的使用和某些未知原因,遥控器上的某些键已经坏了,不能再起作用了。现在你的任务是,能否告诉Dr.Kong,如何用最少的按键次数来将频道从编号X切换到编号Y。 【标准输入】

第一行: N 表示有N组测试数据。 (1<=N<=5)

对每组测试数据有5行,前4行包含遥控器上每个按键的信息。0表示对应的键坏了,1表示对应的键可以使用。第5行包含2个整数,分别是X 和 Y (0 <= X <= 99; 0 <= Y <= 99)。 【标准输出】

对每组测试数据输出一行,即将频道从编号X切换到编号Y所需要的最小按键次数。如果不可能将频道从编号X 切换到编号Y,则输出-1. 【 样 例 】

标准输入 标准输出 2 0 0 1 1 1 1 1 1 1 1 1 1 1 23 52 1 1 1 0 1 1 1 0 1 0 1 0 1 23 52

4 -1 【 T5 】

奇妙的图案

最近,Dr. Kong对几何图形发生了浓厚的兴趣。他发现在一个凸多边形里随意加上几个等半径的圆,再将圆涂成不同的颜色,就能构造出一幅美妙的图案。进而,Dr. Kong大发灵感,在此图案的基础上,又加入了几条连接凸多边形的两个不相邻顶点的直线,图形更加奇妙。

这时,Dr. Kong遇到了一个问题,他不想让加入的直线相互交叉,也不想让加入的直线穿过凸多边形里的任何一个圆,甚至不能与任何圆相切。

已经知道凸多边形的N个顶点的坐标,也知道了其中M个圆的圆心坐标和半径R。你能帮助Dr. Kong计算出可加上的满足所有条件的最多直线数吗? 【标准输入】

第1行: N M R 三个正整数

接下来有N行, 每一行为凸多边形一个坐标TXi TYi (i=1,?,N) 再接下来有M行,每一行为一个圆的圆心坐标PXj PYj (j=1,?,M) 【标准输出】

输出有一个整数, 表示可加上的最多直线数。 【约束条件】

5≤ N ≤150 0≤ M ≤100 1≤ R ≤100,000 0≤ 所有坐标X,Y≤100,000 【 样 例 】

标准输入 5 3 1 6 10 10 7 9 1 2 0 0 3 2 2 5 6 8 3 标准输出 1 【T6】

Metric Matrice

Given as input a square distance matrix, where a[i][j] is the distance between point i and point j, determine if the distance matrix is \ metric\

A distance matrix a[i][j] is a metric if and only if 1. a[i][i] = 0

2, a[i][j]> 0 if i != j 3. a[i][j] = a[j][i]

4. a[i][j] + a[j][k] >= a[i][k] i ? j ? k 【Standard input】

The first line of input gives a single integer, 1 ≤ N ≤ 5, the number of test cases. Then follow, for each test case,

* Line 1: One integer, N, the rows and number of columns, 2 <= N <= 30 * Line 2..N+1: N lines, each with N space-separated integers

(-32000 <=each integer <= 32000).

【Standard output】

Output for each test case , a single line with a single digit, which is the lowest digit of the possible facts on this list: * 0: The matrix is a metric

* 1: The matrix is not a metric, it violates rule 1 above * 2: The matrix is not a metric, it violates rule 2 above * 3: The matrix is not a metric, it violates rule 3 above * 4: The matrix is not a metric, it violates rule 4 above 【Sample Input】 【Sample Output】 2 0 4 3

0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0

2 0 3 2 0

【 T7 】

Divideing Jewels

Mary and Rose own a collection of jewells. They want to split the collection among themselves so that both receive an equal share of the jewels. This would be easy if all the jewels had the same value, because then they could just split the collection in half. But unfortunately, some of the jewels are larger, or more beautiful than others. So, Mary and Rose start by assigning a value, a natural number between one and ten, to each jewel. Now they want to divide the jewels so that each of them gets the same total value. Unfortunately, they realize that it might be impossible to divide the jewels in this way (even if the total value of all jewels is even). For example, if there are one jewel of value 1, one of value 3 and two of value 4, then they cannot be split into sets of equal value. So, they ask you to write a program that checks whether there is a fair partition of the jewels. 【Standard input】

Each line in the input file describes one collection of jewels to be divided. The lines contain ten non-negative integers n1 , . . . , n10 , where ni is the number of jewels of value i. The maximum total number of jewells will be 10000.

The last line of the input file will be \ 【Standard output】

For each collection, output \#k:\either \Can be divided.\Can't be divided.\ Output a blank line after each test case. 【Standard input】 1 0 1 2 0 0 0 0 2 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 【Standard output】 #1:Can't be divided. #2:Can be divided.

【 T8 】

Interesting Punch-Bowl

Dr.Kong has taken a side job designing interesting punch-bowl designs. The designs are created as follows:

* A flat board of size W cm * H cm is procured (3 <= W <= 300, 3 <= H <= 300)


河南省程序设计大赛历年真题(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2013-2014麓山国际第一次月考解析最终版本

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: