ACM (UVa) : 11040


x

a

b

p

q

r

x = a + b
a = p + q
b = q + r

so, x = p + q + q + r
x = p + 2q + r
2q = x – (p + r)
q = (x – (p + r)) / 2

3

a

b

2

x

1

3 = a + b
a = 2 + x
b = x + 1

so, 3 = 2 + x + x + 1
3 = 2 + 2x + 1
2x = 3 – 3
therefore, x = 0

3

a

b

2

0

1

a = 2 + 0 = 2
b = 0 + 1 = 1

3

2

1

2

0

1

Similarly, thy to solve these block ..
1.

3

a

b

1

x

2

2.

5

a

b

2

x

1

3.

2

a

b

1

x

1

After solving these block, u will get all the values of ninth row. Then run a recursive process to find all upper cells value.

// to avoid ‘Presentation Error’:
do not print an extra space (‘ ‘) after each line of output

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s