
Coprime Permutation
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 […]
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 […]
The Prodiggers are quite a cool band and for this reason, they have been the surprise guest at the ENTER festival for the past 80 […]
Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, […]
Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their […]
Hongcow’s teacher heard that Hongcow had learned about the cyclic shift, and decided to set the following problem for him. You are given a list […]
One day, Hongcow goes to the store and sees a brand new deck of n special cards. Each individual card is either red or blue. He decides […]