IOM 2018, Блиц, английски — Задача 31

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

Условие

Determine the output of the following program:

C++ program listing with line numbers 1 to 26: a global counter k and a vector of 17 booleans t initialised to true; a recursive function f(l, r) increments k, returns t[l] when l == r, otherwise splits at mid = (l + r) / 2 and combines f(l, mid) and f(mid + 1, r) with || when (int)log2(r - l + 1) % 2 == 1 and with && otherwise; main marks t[1] false, sieves the composite indices below 17 to false, calls f(1, 16) and prints k.

Отговори

Решение


Оригинал в Архива: blitz.pdf · официални решения: blitz-answers.pdf