IOM 2019, Блиц — Задача 20

OLYMPIAD OF METROPOLISES, Moscow, September 2, 2019 · 2 септември 2019 г.

Условие

Determine the output of the following program:

C++ listing, 19 numbered lines: global const int n = 100 and int answer = 0; a recursive function f(int l, int r, int ql, int qr) that increments answer, returns if qr is less than l or ql is greater than r, returns if ql is at most l and qr is at least r, otherwise sets mid to (l + r) shifted right by 1 and calls f(l, mid, ql, qr) and f(mid + 1, r, ql, qr); main sets l = 2, r = 33, calls f(1, n, l, r) and prints answer.

Решение

Внимание: Непълно решение

В архива няма официално решение на тази задача.


Оригинал в Архива: blitz-en-all-task-final.pdf