
Month: May 2020





Not Wool Sequences
A sequence of non-negative integers a 1, a 2, …, a n of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that . In other words each wool sequence contains a […]

World Eater Brothers
You must have heard of the two brothers dreaming of ruling the world. With all their previous plans failed, this time they decided to cooperate […]

Boring Partition
This problem is the most boring one you’ve ever seen. Given a sequence of integers a 1, a 2, …, a n and a non-negative integer h, our goal is to partition the sequence […]

Meeting Her
Urpal lives in a big city. He has planned to meet his lover tonight. The city has n junctions numbered from 1 to n. The junctions are connected by m directed streets, […]

The Brand New Function
Polycarpus has a sequence, consisting of n non-negative integers: a 1, a 2, …, a n. Let’s define function f(l, r) ( l, r are integer, 1 ≤ l ≤ r ≤ n) for sequence a as an operation of bitwise OR of all the sequence elements with indexes […]

Colorado Potato Beetle
Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up […]


Points on Line
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he […]

Playing with Permutations
Little Petya likes permutations a lot. Recently his mom has presented him permutation q 1, q 2, …, q n of length n. A permutation a of length n is a sequence of integers a 1, a 2, …, a n (1 ≤ a i ≤ n), all integers there are distinct. […]


Number Transformation
Little Petya likes positive integers a lot. Recently his mom has presented him a positive integer a. There’s only one thing Petya likes more than numbers: […]

Adding Digits
Vasya has got two number: a and b. However, Vasya finds number a too short. So he decided to repeat the operation of lengthening number a n times. One operation of lengthening a […]

Ancient Prophesy
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters […]

Balls and Boxes
Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right. […]

Dividing Kingdom
A country called Flatland is an infinite two-dimensional plane. Flatland has n cities, each of them is a point on the plane. Flatland is ruled by king […]

Black and White Tree
The board has got a painted tree graph, consisting of n nodes. Let us remind you that a non-directed graph is called a tree if it is […]