ACSL Intermediate
ACSL Intermediate
2017-2018 Contest #1
Intermediate Division Short Problems
3. Recursive Functions
4. Recursive Functions
a = 1: b = 2: c = 3: d = 4: e = 4: f = 6
if (d / b) < (f / a) then d = d / b
a = f ↑ b / c ↑ (d / b)
if (a <= f) && (b > e) then a = f else b = e
if abs(c - f) != int(f / c) then c = f / c else f = f / c
if (a = = b) | | (c = = d) then a = a + b
c=c+d
output (b * c) * (f + d) / a / 2 * d - c + e ↑ (b - 2 * d)
American Computer Science League
2017-2018 Contest #1
Intermediate Division – Solutions to Short Problems
3. Recursive Functions
3. 191
The original T has 2 segments. The next step adds 3 more segments for a
total of 5. The next step adds 6 segments for a total of 11. Next 12
segments are added for 23. The sequence formed is:
4. Recursive Functions
4. 525
f( 12,7 ) = f(12 - 1,7 + 2 ) + 3 = f(11,9 ) + 3 = 522 + 3 = 525
f(11,9 ) = f( 11 - 1,9 + 2 ) + 3 = f(10,11 ) + 3 = 519 + 3 = 522
f( 10,11 ) = 2 * f(10 + 1,11 - 1 ) - 5 = 2 * f( 11,10 ) - 5 = 2*262−5 = 519
f( 11,10 ) = f( 11 - 1,10 + 2 ) + 3 = f( 10,12 ) + 3 = 259 + 3 = 262
f(10,12 ) = 2 * f(10 + 1,12 - 1 ) - 5 = 2 * f( 11,11 ) - 5 = 2*132−5 = 259
f( 11,11 ) = 11*11+11= 132 Now substitute backwards.
American Computer Science League
2017-2018 Contest #1
Intermediate Division – Solutions to Short Problems
a b c d e f
1 2 3 4 4 6
1 2 3 2 4 6
12 2 3 2 4 6
12 4 3 2 4 6
12 4 2 2 4 6
16 4 2 2 4 6
16 4 4 2 4 6
(b * c) * (f + d) / a / 2 * d - c + e ↑ (b - 2 * d)
= (4 * 4) *(6 + 2) / 16 / 2 * 4 - 4 + 4 ↑ (4 - 2 * 2)
= 16 * 8 / 16 / 2 * 4 - 4 + 40
= 128 / 16 / 2 * 2 - 4 + 1 = 8 / 2 * 2 - 4 + 1 = 5