URAL 1928 1962 1939 1994, ural1939
XGG Blog
- URAL1928 Another Ecology Problem
- URAL1962 In Chinese Restaurant
- URAL1939 First Seal
- URAL1994 The Emperor's plan
URAL1928 Another Ecology Problem
Letdp[n][centra][0]
Be the maximum money the centra can get when there isn
Billions zollars in the budget and is the current centra's turn to request for money, and letdp[n][centra][1]
Be the minimum money the consorcan get when money is maximized for the current centra. I ≤ n ,dp[n][centra][0]=dp[n-i][1-centra][1] + i
,dp[n][centra][1]=dp[n-1][1-centra][0]
, And when K> n ,dp[n][centra][0]=m
,dp[n][centra][1]=0
. Find the maximumdp[n][centra][0]
And the minimumdp[n][centra][1]
To solve this problem.
Accepted Code
URAL1962 In Chinese Restaurant
The people form chains and circle. The circle (number of nodes is greater than 2) cocould only appear when there is only one set and N = m , And the answer is2
If N> 2 . Each chain shoshould contain at most 1 inner cycle which indicates two people want to sit with each other. For every chain it cocould be reversed, and it cocould be placed anywhere else t the chain contains people1
. Denote the number of chainsk
, The permutation of the chains is (K−1 )! , Denote the number of chains whose node number is larger than 1l
, The number of available arrangements is (K−1 )! Limit 2l .
Accepted Code
URAL1939 First Seal
Let T = h−hx , S_1 = v then t −l , S_2 = v22a , If S1 <S2 Then the vehicle will fall to pieces anyway.
Accepted Code
URAL1994 The Emperor's plan
Letdp[x][y]
Be the expected number of senators before night,x
Is the number of senators andy
Is the number of spies. In each night,y
Senators will be removed thusx -= y
Is executed. In each day, enumerate 0 ≤ I ≤ x + y And 0 ≤ j ≤ min (I, y) Where I Is the number of people to be excluded, J Is the number of spies in them. The expectationdp[x][y]
Will be Max_ I = 0x + y Σ _ j = 0 min (I, y) dp [x − (I −j)] [y −j] ⋅ C_xi −j ⋅ C_yjC_x + yi .
Accepted Code