
Kay and Eternity
Snow Queen told Kay to form a word “eternity” using pieces of ice. Kay is eager to deal with the task, because he will then […]
Snow Queen told Kay to form a word “eternity” using pieces of ice. Kay is eager to deal with the task, because he will then […]
Gerda is travelling to the palace of the Snow Queen. The road network consists of n intersections and m bidirectional roads. Roads are numbered from 1 to m. Snow Queen put a […]
Alice wants to send an important message to Bob. Message a = (a 1, …, a n) is a sequence of positive integers (characters). To compress the message Alice wants to use binary […]
Two positive integers are coprime if and only if they don’t have a common divisor greater than 1. Some bear doesn’t want to tell Radewoosh how […]
Bearland is a dangerous place. Limak can’t travel on foot. Instead, he has k magic teleportation stones. Each stone can be used at most once. The i-th stone allows […]
The only king stands on the standard chess board. You are given his position in format “cd”, where c is the column from ‘a’ to ‘h’ and d is […]
You are given n points on a line with their coordinates x i. Find the point x so the sum of distances to the given points is minimal. Input The first […]
zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters ‘a’. He is too lazy to write […]
Find an n × n matrix with different numbers from 1 to n 2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd […]
You should process m queries over a set D of strings. Each query is one of three kinds: Add a string s to the set D. It is guaranteed that the string s was […]
You are given two arithmetic progressions: a 1 k + b 1 and a 2 l + b 2. Find the number of integers x such that L ≤ x ≤ R and x = a 1 k‘ + b 1 = a 2 l‘ + b 2, for some integers k‘, l‘ ≥ 0. Input The only line contains six integers a 1, b 1, a 2, b 2, L, R (0 < a 1, a 2 ≤ 2·109, - 2·109 ≤ b 1, b 2, L, R ≤ 2·109, L ≤ R). Output Print the […]
Dexterina and Womandark have been arch-rivals since they’ve known each other. Since both are super-intelligent teenage girls, they’ve always been trying to solve their disputes […]
Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they […]
I see a pink boar and I want it painted black. Black boars look much more awesome and mighty than the pink ones. Since Jaggy […]
I’m strolling on sunshine, yeah-ah! And doesn’t it feel good! Well, it certainly feels good for our Heroes of Making Magic, who are casually walking […]
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He […]
Welcome to the world of Pokermon, yellow little mouse-like creatures, who absolutely love playing poker! Yeah, right… In the ensuing Pokermon League, there are n registered Pokermon […]