1. 程式人生 > >2016河南省第九屆ACM程式設計競賽【正式賽真題】

2016河南省第九屆ACM程式設計競賽【正式賽真題】

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

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  

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

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

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

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上都有,可以提交