You are on page 1of 3

online-judge.uva.

es Problem Set Archive 10743 - Blocks on Blocks


December 30, 2004
This is the proof of the solution to the problem from online-judge.uva.es: 10743 - Blocks on Blocks. The problem statement can be found at the URL: http://acm.uva.es/p/v107/10743.html. k Let An be the number of gures composed of n squares. Let Bn be the number of gures composed of n squares such that the top row of the gure contains k squares. Further de ne A0 to be 0 to make our lives easier. By de nition, for n 1

An

X = B
n k=1

k n

(1)

k Consider Bn , if the top row is removed, the remained gure contains n k squares. Let r be the number of squares of the top row of the remained gure. Then r must be within 1 to n k. Note that there are k + r 1 ways to place a k-square row on top another (n k)-square gure with r squares on top to construct a new n-square gure with k squares on top. Thus, for n > k 1, we have,

B =
k n

n k r=1

X (k + r

r 1)Bn

(2)

The rest of the proof is almost completely algebraic. i.e. We do not need to make use of the combinatorial properties of the gure any more. The rst goal is to develop a recurence k relation of An without involving Bn . From (2) and (1), for n > k 1,
k+1 Bn+1 = n k r n k r=1

X (k + 1 + r 1)B =1 X B + X (k + r
r n k n k r=1

r n k r 1)Bn

k = An k + Bn

(3)
1 1

Note that this is also true for n = k since we de ned A0 = 0. i.e. For n k > 1,
k k Bn = An k + Bn

(4)

From (1) and (4), for n > 1,

1 An = Bn +

= = = = From (2), (1) and (4), for n > 2,


1 Bn =

X1 B + B =2 X1 1 1 B 1 + (A + B 1 ) + B 1 =2 X1 X1 1 1 B1 + A + B 1 + B 1 =2 =2 2 1 X X B1 + A + B 1 =1 =1 1 X B1 + A
n k n k n n n n k n n k k n n n n k n k n n k k n n n n k n k n k k n n k=1 k

(5)

r=1

X1 rB

= An 1 + = An = An

X1(r =2 X1(r 1+ =2 X3(n 1+


n r n r n r=0

r n

r 1)Bn 1 r 1)(An 1 r + Bn 1 ) 2

1 = Bn 1 + A n 1 +

r=0

X3(n
k

2 r )Ar +

r=1

X2 rB

r n

2 r)Ar

(6)

1 We can then apply (6) iteratively to get Bn. i.e. For n > 2, 1 1 Bn = B2 +
n k n k

= = = =

X (B 1 B 1 1 ) =3 X X3 1 + (A 1 + (k 2 r )A ) =0 =3 1 X X X3(k 2 r)A 1+ A + =2 =3 =0 1 X X3 X (k 2 r)A A1 + A + =0 =3+ =2 1 3 (n r 2)(n r 1) XA +X A


k r k n k k r n k r k n k k r n r n k k r r n n k=1 k r=0

(7)

It turns out that (7) is also ture for n=2. By substituting (7) into (5), we have, for n > 1,

An = 2

k=1

X1 A + X3 (n
n k r=0 n

r 2)(n r 1) A r 2

(8)

Therefore, we have our rst recurrence relation An. We then need to simplify it. For n > 1, consider An+1 An,

An+1 An = 2An + An 2 +
= 2A n + A n

An+1 = 3An + An
i.e. For n > 2,

X3( (n =1 X3 + (n 2 =1 X3 + (n 2
r n r n r=1

r 1)(n r) (n r 2)(n r 1) )A r 2 2 r 1)Ar r 1)Ar


n

(9)

An = 3An 1 + An 3 +
For n > 2, consider An+1 An again,

r=1

X4(n

r 2)Ar
n

(10)

An+1 An = 3An 3An 1 + An

An 3 + 2An 3 +
n r=1

= 3An 3An 1 + An 2 + An 3 +

An+1 = 4An 3An 1 +


i.e. For n > 3,

r=1

X2 A

X4 A

r=1

X4((n

r 1) (n r 2))Ar

(11)

An = 4An

1 3A n 2 +

r=1

X3 A

(12)

Note that in (8), the coe cients of the recurrence relation is quadratic to n. And they are linear to n in (10). They are now simpli ed to constants in (12). If we apply the same technique again, we will get the third order linear recurrence relation of An for n > 4.

You might also like