A题:表达式求值
时间限制:1000 ms | 内存限制:65535 KB
- 描述
- 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式。2. 如果 X 和 Y 是 表达式,则 X+Y, X*Y 也是表达式; *优先级高于+.3. 如果 X 和 Y 是 表达式,则 函数 Smax(X,Y)也是表达式,其值为:先分别求出 X ,Y值的各位数字之和,再从中选最大数。4.如果 X 是 表达式,则 (X)也是表达式。例如:表达式 12*(2+3)+Smax(333,220+280) 的值为 69。请你编程,对给定的表达式,输出其值。
- 输入
- 【标准输入】 第一行: T 表示要计算的表达式个数 (1≤ T ≤ 10) 接下来有 T 行, 每行是一个字符串,表示待求的表达式,长度<=1000
- 输出
- 【标准输出】 对于每个表达式,输出一行,表示对应表达式的值。
- 样例输入
-
3 12+2*3 12*(2+3) 12*(2+3)+Smax(333,220+280)
- 样例输出
-
18 60 69
- 题解:http://blog.csdn.net/liu940204/article/details/51913458
B题:宣传墙
时间限制:1000 ms | 内存限制:65535 KB
- 描述
-
ALPHA 小镇风景美丽,道路整齐,干净,到此旅游的游客特别多。CBA 镇长准备在一条道路南面 4*N 的墙上做一系列的宣传。为了统一规划,CBA 镇长要求每个宣传栏只能占相邻的两个方格位置。但这条道路被另一条道路分割成左右两段。CBA 镇长想知道,若每个位置都贴上宣传栏,左右两段各有有多少种不同的张贴方案。例如: N=6,M=3, K=2, 左,右边各有 5 种不同的张贴方案
- 输入
- 第一行: T 表示以下有 T 组测试数据 ( 1≤T ≤8 )
接下来有T行, 每行三个正整数 N M K 分别表示道路的长度,另一条道路的起点和宽度
(1≤ N ,M ≤ 1 000 000, 1≤ K ≤ 100000)
- 输出
- 每组测试数据,输出占一行:两个整数,分别表示左右两段不同的张贴方案数。由于方案总数
可能很大,请输出对 997 取模后的结果。
- 样例输入
-
2 6 3 2 5 3 2
- 样例输出
-
5 5 5 1
C题:信道安全
时间限制:1000 ms | 内存限制:65535 KB
- 描述
- Alpha 机构有自己的一套网络系统进行信息传送。情报员 A 位于节点 1,他准备将一份情报发送给位于节点 n 的情报部门。可是由于最近国际纷争,战事不断,很多信道都有可能被遭到监视或破坏。经过测试分析,Alpha 情报系统获得了网络中每段信道安全可靠性的概率,情报员 A 决定选择一条安全性最高,即概率最大的信道路径进行发送情报。你能帮情报员 A 找到这条信道路径吗?
- 输入
- 第一行: T 表示以下有 T 组测试数据 ( 1≤T ≤8 )
对每组测试数据:
第一行:n m 分别表示网络中的节点数和信道数 (1<=n<=10000,1<=m<=50000)
接下来有 m 行, 每行包含三个整数 i,j,p,表示节点 i 与节点 j 之间有一条信道,其信
道安全可靠性的概率为 p%。 ( 1<=i, j<=n 1<=p<=100)
- 输出
- 每组测试数据,输出占一行,一个实数 即情报传送到达节点 n 的最高概率,精确到小数点后
6 位。
- 样例输入
-
1 5 7 5 2 100 3 5 80 2 3 70 2 1 50 3 4 90 4 1 85 3 1 70
- 样例输出
-
61.200000
- 题解:http://blog.csdn.net/liu940204/article/details/51954554
D题:导弹发射
时间限制:1000 ms | 内存限制:65535 KB
- 描述
-
Alpha 机构研发出一种新型智能导弹,它能够在雷达检测到的区域内,选择一条前进的路径,击破路径上所有的目标物。雷达位于(0,0)处,它能够检测到两条射线之间的区域(不妨设在第一象限)。导弹一开始置放在(0,0)处,它可以在雷达能检测到的区域内先选择一个目标物击破,然后再继续前进,选择另一个目标物击破。注意,导弹不能沿着这两条射线前进,当然也不能停在原地。可以假设,导弹一旦发射,其能量无比大,前进的路径无限长。已知雷达能够检测到区域,其射线 1:ax-by=0 和射线 2:cx-dy=0。Alpha 机构的总指挥希望在发现目标群的第一时刻,计算出一条可以击破最多目标物的路径。- 输入
- 第一行: T 表示以下有 T 组测试数据(1≤T ≤8)
对每组测试数据:
第 1 行: n 表示目标物的个数
第 2 行: a b c d 代表两条射线的斜率分别是 a/b 和 c/d。
接下来有 n 行,每行 2 个正整数 xi yi 即第 i 个目标物的坐标。
【约束条件】
(1) n<=10^5 0<=a, b, c, d<=10^5 a 和 b 不会同时为 0,c 和 d 不会同时为 0;
(2) 0<= xi , yi <=10^6 i=1,…..,n
- 输出
- 每组测试数据,输出占一行,即导弹能击破的最多目标数。
- 样例输入
-
1 15 1 3 2 1 3 1 6 2 4 2 2 5 4 5 6 6 3 4 1 6 2 1 7 4 9 3 5 3 1 3 15 5 12 4
- 样例输出
-
4
E题:机器设备
时间限制:1000 ms | 内存限制:65535 KB
- 描述
-
Alpha 公司设计出一种节能的机器设备。它的内部结构是由 N 个齿轮组成。整个机器设备有一个驱动齿轮,当启动它时,它立即按 10,000 圈/小时转速顺时针转动,然后它又带动与它相切的齿轮反方向,即逆时针转动。齿轮之间互相作用,每个齿轮都可能驱动着多个齿轮,最终带动一个工作齿轮完成相应的任务。 在这套设备中,记录了每个齿轮的圆心坐标和齿轮半径。已知驱动齿轮位于(0,0),最终的工作齿轮位于(Xt, Yt)。 Alpha 公司想知道传动序列中所有齿轮的转速。所谓传动序列,即能量由驱动齿轮传送,最后到达工作齿轮的过程中用到的所有齿轮。能量传送过程是,在一个半径为
R,转速为 S 圈/每小时的齿轮的带动下,与它相切的半径为 R’的齿轮的转速为-S*R/R’ 转/小时。负号的意思是, 表示按反方向转动。已知,机器设备中除了驱动齿轮以外,所有齿轮都可能被另外某个齿轮带动,并且不会出现2 个不同的齿轮带动同一个齿轮的情况。你的任务是计算整个传动序列中所有齿轮的能量之和。即所有齿轮转速的绝对值之和。
- 输入
- 第一行: T 表示以下有 T 组测试数据(1≤T ≤8)
对每组测试数据:
第 1 行: N Xt Yt (2≤N ≤1100)
接下来有 N 行, Xi Yi Ri 表示 N 个齿轮的坐标和半径 i=1,2,….,N
( -5000 ≤Xi ,Yi ≤ 5000 3 ≤ Ri ≤ 1000 )
坐标以及半径是整数
- 输出
- 每组测试数据,输出占一行,即所有齿轮转速的绝对值之和 在double范围内,输出整数部分
- 样例输入
-
1 4 32 54 0 30 20 0 0 10 32 54 20 -40 30 20
- 样例输出
-
20000
- 题解:http://blog.csdn.net/liu940204/article/details/51934369
F题:Decimal integer conversion
时间限制:1000 ms | 内存限制:65535 KB
- 描述
- XiaoMing likes mathematics, and he is just learning how to convert numbers between differentbases , but he keeps making errors since he is only 6 years old. Whenever XiaoMing converts anumber to a new base and writes down the result, he always writes one
of the digits wrong.For example , if he converts the number 14 into binary (i.e., base 2), the correct result should be"1110", but he might instead write down "0110" or "1111". XiaoMing never accidentally adds ordeletes digits, so he might write down a number
with a leading digit of " 0" if this is the digit shegets wrong.Given XiaoMing ‘s output when converting a number N into base 2 and base 3, please determinethe correct original value of N (in base 10). (N<=10^10)You can assume N is at most 1 billion, and that
there is a unique solution for N.- 输入
- The first line of the input contains one integers T, which is the nember of test cases (1<=T<=8)
Each test case specifies:
* Line 1: The base-2 representation of N , with one digit written incorrectly.
* Line 2: The base-3 representation of N , with one digit written incorrectly.
- 输出
- For each test case generate a single line containing a single integer , the correct value of N
- 样例输入
-
1 1010 212
- 样例输出
-
14
- 题解:http://blog.csdn.net/liu940204/article/details/51913600
-
G题:Prototypes analyze
时间限制:1000 ms | 内存限制:65535 KB
- 描述
-
ALpha Ceiling Manufacturers (ACM) is analyzing the properties of its new series of Incredibly Collapse-Proof Ceilings (ICPCs). An ICPC consists ofn layers
of material, each with a different value of collapse resistance (measured as a positive integer). The analysis ACM wants to run will take the collapse-resistance values of the layers, store them in a binary search tree, and check whether the shape of this
tree in any way correlates with the quality of the whole construction. Because, well, why should it not? To be precise, ACM takes the collapse-resistance values for the layers, ordered from
the top layer to the bottom layer, and inserts them one-by-one into a tree. The rules for inserting a value v are:? If the tree is empty, make v the root of the tree.
? If the tree is not empty, compare v with the root of the tree.
? If v is smaller, insert v into the left subtree of the root,
? otherwise insert v into the right subtree.
ACM has a set of ceiling prototypes it wants to analyze by trying to collapse them. It wants to take each group of ceiling prototypes that have trees of the same shape and analyze them together. For example , assume ACM is considering
five ceiling prototypes with three layers each, as described by Sample Input 1 and shown in Figure C.1. Notice that the first prototype’s top layer has collapseresistance value 2, the middle layer has value 7, and the bottom layer has value 1. The second prototype
has layers with collapse-resistance values of 3, 1, and 4 – and yet these two prototypes induce the same tree shape, so ACM will analyze them together. Given a set of prototypes, your task is to determine how many different tree shapes they induce.- 输入
- The first line of the input contains one integers T, which is the nember of test cases (1<=T<=8).
Each test case specifies :
● Line 1: two integers n (1 ≤ n ≤ 50), which is the number of ceiling prototypes to analyze,
and k (1 ≤ k ≤ 20), which is the number of layers in each of the prototypes.
● The next n lines describe the ceiling prototypes. Each of these lines contains k distinct
integers ( between 1 and 1e6, inclusive ) , which are the collapse-resistance values of the
layers in a ceiling prototype, ordered from top to bottom.
- 输出
- For each test case generate a single line containing a single integer that is the number of different tree
shapes.
- 样例输入
-
15 32 7 11 5 93 1 42 6 59 7 3
- 样例输出
-
4
- 题解:http://blog.csdn.net/liu940204/article/details/51954172
H题:Music Works
时间限制:1000 ms | 内存限制:65535 KB
- 描述
-
CBA company specializes in online music. It tries to parade itself into an open music market. Musicians and bands can make their own works to the CBA site, sold directly to consumers.Mika Grady ready to use a computer to imitate N kinds of musical instruments, to creative works. Each instrument has an audio range [ai, bi].
Mika Grady line up all the instruments. A musical instrument can not play, But when it is played,its audio must be higher than all the front instruments.
Mika Grady is very excited, he wants to know if he can create many different works.
- 输入
- The first line of the input contains one integers T, which is the nember of test cases (1<=T<=8).
Each test case specifies:
* Line 1: N which is N kinds of musical instruments(1 ≤ N≤ 500 )
*The next n lines : ai bi describe the audio range of each instrument.
(1 ≤ ai ≤ bi ≤ 10^9)
- 输出
- For each test case generate a single line containing a single integer that is the number of different works.
but,only output the remainder of the mode 1,000,000,007.
- 样例输入
-
1 2 1 2 2 3
- 样例输出
-
7
- 提示
- data ensure : (b1-a1)+(b2-a1)+……+(bn-an)<=10^6
提示:这些题在nyoj上都有,可以提交