task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Title: Tree of Life (medium) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Heidi got tired of deciphering the prophecy hidden in the Tree of Life and decided to go back to her headquarters, rest a little and try there. Of course, she cannot uproot the Tree and take it with her, so she ma...
1,900
Title: Cookies Time Limit: 1 seconds Memory Limit: 256 megabytes Problem Description: Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square *k*<=Γ—<=*k* in size, divided into blocks 1<=Γ—<=1 in size and paint there the main diagonal together with cells, which li...
1,901
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given ...
1,902
Title: Canvas Frames Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin w...
1,903
Title: Tricky Sum Time Limit: None seconds Memory Limit: None megabytes Problem Description: In this problem you are to calculate the sum of all integers from 1 to *n*, but you should take all powers of two with minus in the sum. For example, for *n*<==<=4 the sum is equal to <=-<=1<=-<=2<=+<=3<=-<=4<==<=<=-<=4, be...
1,904
Title: Find a car Time Limit: None seconds Memory Limit: None megabytes Problem Description: After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his ...
1,905
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let *next*...
1,906
Title: Indian Summer Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy β€” she doesn't take a leaf if it matches the color and the specie...
1,907
Title: Dirty Arkady's Kitchen Time Limit: None seconds Memory Limit: None megabytes Problem Description: Arkady likes to walk around his kitchen. His labyrinthine kitchen consists of several important places connected with passages. Unfortunately it happens that these passages are flooded with milk so that it's impo...
1,908
Title: Furlo and Rublo and Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Furlo and Rublo play a game. The table has *n* piles of coins lying on it, the *i*-th pile has *a**i* coins. Furlo and Rublo move in turns, Furlo moves first. In one move you are allowed to: - choose some pil...
1,909
Title: Reorder the Array Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find t...
1,910
Title: Good Substrings Time Limit: None seconds Memory Limit: None megabytes Problem Description: You've got string *s*, consisting of small English letters. Some of the English letters are good, the rest are bad. A substring *s*[*l*...*r*] (1<=≀<=*l*<=≀<=*r*<=≀<=|*s*|) of string *s*<=<==<=<=*s*1*s*2...*s*|*s*| (wh...
1,911
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant loves to play with color cards. He has *n* cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In ...
1,912
Title: Santa Claus and Candies Time Limit: None seconds Memory Limit: None megabytes Problem Description: Santa Claus has *n* candies, he dreams to give them as gifts to children. What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer n...
1,913
Title: Vanya and Computer Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vanya and his friend Vova play a computer game where they need to destroy *n* monsters to pass a level. Vanya's character performs attack with frequency *x* hits per second and Vova's character performs attack w...
1,914
Title: Tourist Time Limit: 0 seconds Memory Limit: 256 megabytes Problem Description: Tourist walks along the *X* axis. He can choose either of two directions and any speed not exceeding *V*. He can also stand without moving anywhere. He knows from newspapers that at time *t*1 in the point with coordinate *x*1 an in...
1,915
Title: The Child and Set Time Limit: None seconds Memory Limit: None megabytes Problem Description: At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers some...
1,916
Title: Remainders Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Today Pari and Arya are playing a game called Remainders. Pari chooses two positive integer *x* and *k*, and tells Arya *k* but not *x*. Arya have to find the value . There are *n* ancient numbers *c*1,<=*c*2,<=...,<=*...
1,917
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice ...
1,918
Title: Clique Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph *G*. It is required to find a subset of vertices *C* of the m...
1,919
Title: Research Rover Time Limit: None seconds Memory Limit: None megabytes Problem Description: Unfortunately, the formal description of the task turned out to be too long, so here is the legend. Research rover finally reached the surface of Mars and is ready to complete its mission. Unfortunately, due to the mist...
1,920
Title: Hashing Trees Time Limit: None seconds Memory Limit: None megabytes Problem Description: Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she gue...
1,921
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: One day student Vasya was sitting on a lecture and mentioned a string *s*1*s*2... *s**n*, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by com...
1,922
Title: Leaving Auction Time Limit: None seconds Memory Limit: None megabytes Problem Description: There are *n* people taking part in auction today. The rules of auction are classical. There were *n* bids made, though it's not guaranteed they were from different people. It might happen that some people made no bids ...
1,923
Title: Xenia and Hamming Time Limit: None seconds Memory Limit: None megabytes Problem Description: Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance. The Hamming distance between two strings *s*<==<=*s*1*s*2... *s**n* and *t*<==<=*t*1*t*2... *t**n* of equal length *n* is...
1,924
Title: Bath Queue Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: There are *n* students living in the campus. Every morning all students wake up at the same time and go to wash. There are *m* rooms with wash basins. The *i*-th of these rooms contains *a**i* wash basins. Every student independ...
1,925
Title: To Play or not to Play Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya and Petya are playing an online game. As most online games, it has hero progress system that allows players to gain experience that make their heroes stronger. Of course, Vasya would like to get as many exp...
1,926
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In mathematical terms, the sequence *F**n* of Fibonacci numbers is defined by the recurrence relation DZY loves Fibonacci numbers very much. Today DZY gives you an array consisting of *n* integers: *a*1,<=*a*2,<=...,<=*a**n*. Mo...
1,927
Title: Maximum in Table Time Limit: None seconds Memory Limit: None megabytes Problem Description: An *n*<=Γ—<=*n* table *a* is defined as follows: - The first row and the first column contain ones, that is: *a**i*,<=1<==<=*a*1,<=*i*<==<=1 for all *i*<==<=1,<=2,<=...,<=*n*. - Each of the remaining numbers in the t...
1,928
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has *n* items in total (each item is unique). You ca...
1,929
Title: AND Graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a set of size $m$ with integer elements between $0$ and $2^{n}-1$ inclusive. Let's build an undirected graph on these integers in the following way: connect two integers $x$ and $y$ with an edge if and only if $...
1,930
Title: Vasya and Digital Root Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you. Let's assume that *S*(*n*) is the sum of digits of number *n*, for example, *S*(4098)<==<=4<=+<=0<=...
1,931
Title: Space mines Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Once upon a time in the galaxy of far, far away... Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star. When the r...
1,932
Title: Dispute Time Limit: None seconds Memory Limit: None megabytes Problem Description: Valera has *n* counters numbered from 1 to *n*. Some of them are connected by wires, and each of the counters has a special button. Initially, all the counters contain number 0. When you press a button on a certain counter, th...
1,933
Title: Downloading B++ Time Limit: None seconds Memory Limit: None megabytes Problem Description: Only *T* milliseconds left before the start of well-known online programming contest Codehorses Round 2017. Polycarp needs to download B++ compiler to take part in the contest. The size of the file is *f* bytes. Polyc...
1,934
Title: From Y to Y Time Limit: None seconds Memory Limit: None megabytes Problem Description: From beginning till end, this message has been waiting to be conveyed. For a given unordered multiset of *n* lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as string...
1,935
Title: QAQ Time Limit: None seconds Memory Limit: None megabytes Problem Description: "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of length *n*. There is a great number of "QAQ"...
1,936
Title: Vitaly and Cycle Time Limit: None seconds Memory Limit: None megabytes Problem Description: After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked the cycles of an odd length in which each vertex occurs at most once. Vitaly was wondering how to solve...
1,937
Title: Paths in a Complete Binary Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: *T* is a complete binary tree consisting of *n* vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two ch...
1,938
Title: Encrypting Messages Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help. A mes...
1,939
Title: Leaving the Bar Time Limit: None seconds Memory Limit: None megabytes Problem Description: For a vector $\vec{v} = (x, y)$, define $|v| = \sqrt{x^2 + y^2}$. Allen had a bit too much to drink at the bar, which is at the origin. There are $n$ vectors $\vec{v_1}, \vec{v_2}, \cdots, \vec{v_n}$. Allen will make $...
1,940
Title: Spotlights Time Limit: None seconds Memory Limit: None megabytes Problem Description: Theater stage is a rectangular field of size *n*<=Γ—<=*m*. The director gave you the stage's plan which actors will follow. For each cell it is stated in the plan if there would be an actor in this cell or not. You are to pl...
1,941
Title: PolandBall and Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses. You...
1,942
Title: The Best Gift Time Limit: None seconds Memory Limit: None megabytes Problem Description: Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are *n* books on sale from one of *m* genres. In the bookshop, Jack deci...
1,943
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of *i*-th of them is 2*w**i* pounds. In each step, Duff can lift some of the remaining weights...
1,944
Title: Anya and Cubes Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anya loves to fold and stick. Today she decided to do just that. Anya has *n* cubes lying in a line and numbered from 1 to *n* from left to right, with natural numbers written on them. She also has *k* stickers with exc...
1,945
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset. Artem wants to create...
1,946
Title: New Year Snowflake Time Limit: None seconds Memory Limit: None megabytes Problem Description: As Gerald ..., in other words, on a New Year Eve Constantine prepared an unusual present for the Beautiful Lady. The present is the magic New Year snowflake that can make any dream come true. The New Year snowflake ...
1,947
Title: Last Chance Time Limit: None seconds Memory Limit: None megabytes Problem Description: Having read half of the book called "Storm and Calm" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius reading f...
1,948
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them. Beroffice works only with small English letters (i.e. with 2...
1,949
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: In some country live wizards. They love to ride trolleybuses. A city in this country has a trolleybus depot with *n* trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final stat...
1,950
Title: The Monster Time Limit: None seconds Memory Limit: None megabytes Problem Description: As Will is stuck in the Upside Down, he can still communicate with his mom, Joyce, through the Christmas lights (he can turn them on and off with his mind). He can't directly tell his mom where he is, because the monster th...
1,951
Title: Biathlon Track Time Limit: None seconds Memory Limit: None megabytes Problem Description: Recently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoroughly and to build all the necessar...
1,952
Title: Fox And Jumping Time Limit: None seconds Memory Limit: None megabytes Problem Description: Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0. There are also *n* cards, each card ...
1,953
Title: Machine Learning Time Limit: None seconds Memory Limit: None megabytes Problem Description: You come home and fell some unpleasant smell. Where is it coming from? You are given an array *a*. You have to answer the following queries: 1. You are given two integers *l* and *r*. Let *c**i* be the number of oc...
1,954
Title: Running Over The Bridges Time Limit: None seconds Memory Limit: None megabytes Problem Description: Polycarp is playing a game called "Running Over The Bridges". In this game he has to run over *n* bridges from the left to the right. Bridges are arranged one after the other, so the *i*-th bridge begins where ...
1,955
Title: Ciel the Commander Time Limit: None seconds Memory Limit: None megabytes Problem Description: Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has *n* cities connected by *n*<=-<=1 undirected roads, and for any two cities there always exists a path between them. Fox Ciel needs to...
1,956
Title: The Child and Binary Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Our child likes computer science very much, especially he likes binary trees. Consider the sequence of *n* distinct positive integers: *c*1,<=*c*2,<=...,<=*c**n*. The child calls a vertex-weighted rooted bina...
1,957
Title: Little Elephant and LCM Time Limit: None seconds Memory Limit: None megabytes Problem Description: The Little Elephant loves the LCM (least common multiple) operation of a non-empty set of positive integers. The result of the LCM operation of *k* positive integers *x*1,<=*x*2,<=...,<=*x**k* is the minimum pos...
1,958
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a set of size $m$ with integer elements between $0$ and $2^{n}-1$ inclusive. Let's build an undirected graph on these integers in the following way: connect two integers $x$ and $y$ with an edge if and only if $x \&a...
1,959
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a rectangle grid. That grid's size is *n*<=Γ—<=*m*. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates β€” a pair of integers (*x*,<=*y*) (0<=≀<=*x*<=≀<=*n*,<=0<=≀<=*y*<=≀<=...
1,960
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Paul is at the orchestra. The string section is arranged in an *r*<=Γ—<=*c* rectangular grid and is filled with violinists with the exception of *n* violists. Paul really likes violas, so he would like to take a picture including a...
1,961
Title: Amusing Joke Time Limit: None seconds Memory Limit: None megabytes Problem Description: So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's nam...
1,962
Title: Anton and Danik Time Limit: None seconds Memory Limit: None megabytes Problem Description: Anton likes to play chess, and so does his friend Danik. Once they have played *n* games in a row. For each game it's known who was the winnerΒ β€” Anton or Danik. None of the games ended with a tie. Now Anton wonders, w...
1,963
Title: Restoring IPv6 Time Limit: None seconds Memory Limit: None megabytes Problem Description: An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons β€” 8 blocks in total, each block has four hexadecimal digits. He...
1,964
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of *m* points *p*1,<=*p*2,<=...,<=*p**m* with integer coordinates, do the following: denote its initial location b...
1,965
Title: Simple Subset Time Limit: None seconds Memory Limit: None megabytes Problem Description: A tuple of positive integers {*x*1,<=*x*2,<=...,<=*x**k*} is called simple if for all pairs of positive integers (*i*,<=<=*j*) (1<=<=≀<=*i*<=<=&lt;<=<=*j*<=≀<=*k*), *x**i*<=<=+<=<=*x**j* is a prime. You are given an arra...
1,966
Title: Sasha Circle Time Limit: None seconds Memory Limit: None megabytes Problem Description: Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has *n* points, Sasha β€” *m*. Since their subordinates con...
1,967
Title: Analyzing Polyline Time Limit: None seconds Memory Limit: None megabytes Problem Description: As Valeric and Valerko were watching one of the last Euro Championship games in a sports bar, they broke a mug. Of course, the guys paid for it but the barman said that he will let them watch football in his bar only...
1,968
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: 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 O...
1,969
Title: Nikita and stack Time Limit: None seconds Memory Limit: None megabytes Problem Description: Nikita has a stack. A stack in this problem is a data structure that supports two operations. Operation push(x) puts an integer *x* on the top of the stack, and operation pop() deletes the top integer from the stack, i...
1,970
Title: Marmots (medium) Time Limit: None seconds Memory Limit: None megabytes Problem Description: Good job! Now that Heidi is able to distinguish between Poisson and uniform distributions, she is in a good position to actually estimate the populations. Can you help Heidi estimate each village's population? Input ...
1,971
Title: Unary Time Limit: None seconds Memory Limit: None megabytes Problem Description: Unary is a minimalistic Brainfuck dialect in which programs are written using only one token. Brainfuck programs use 8 commands: "+", "-", "[", "]", "&lt;", "&gt;", "." and "," (their meaning is not important for the purposes o...
1,972
Title: Beard Graph Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's define a non-oriented connected graph of *n* vertices and *n*<=-<=1 edges as a beard, if all of its vertices except, perhaps, one, have the degree of 2 or 1 (that is, there exists no more than one vertex, whose degree...
1,973
Title: Bear and Company Time Limit: None seconds Memory Limit: None megabytes Problem Description: Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it ...
1,974
Title: Xenia and Tree Time Limit: None seconds Memory Limit: None megabytes Problem Description: Xenia the programmer has a tree consisting of *n* nodes. We will consider the tree nodes indexed from 1 to *n*. We will also consider the first node to be initially painted red, and the other nodes β€” to be painted blue. ...
1,975
Title: Volatile Kite Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given a convex polygon *P* with *n* distinct vertices *p*1,<=*p*2,<=...,<=*p**n*. Vertex *p**i* has coordinates (*x**i*,<=*y**i*) in the 2D plane. These vertices are listed in clockwise order. You can choose a re...
1,976
Title: 000001 Time Limit: None seconds Memory Limit: None megabytes Problem Description: The input contains a single integer *a* (1<=≀<=*a*<=≀<=64). Output a single integer. Input Specification: The input contains a single integer *a* (1<=≀<=*a*<=≀<=64). Output Specification: Output a single integer. Demo Input:...
1,977
Title: The Contest Time Limit: None seconds Memory Limit: None megabytes Problem Description: Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place! This contest consists of *n* problems, and Pasha solves *i*th problem in ...
1,978
Title: Wrath Time Limit: None seconds Memory Limit: None megabytes Problem Description: Hands that shed innocent blood! There are *n* guilty people in a line, the *i*-th of them holds a claw with length *L**i*. The bell rings and every person kills some of people in front of him. All people kill others at the same ...
1,979
Title: The Meaningless Game Time Limit: None seconds Memory Limit: None megabytes Problem Description: Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting. The game consists of multiple rounds. Its rules are very simple: in each round, a natural number *k* is chosen. Th...
1,980
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Alice and Bob begin their day with a quick game. They first choose a starting number *X*0<=β‰₯<=3 and try to reach one million by the process described below. Alice goes first and then they take alternating turns. In the *i*-th tu...
1,981
Title: Harry Potter and the Sorting Hat Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: As you know, Hogwarts has four houses: Gryffindor, Hufflepuff, Ravenclaw and Slytherin. The sorting of the first-years into houses is done by the Sorting Hat. The pupils are called one by one in the alphabe...
1,982
Title: Royal Questions Time Limit: None seconds Memory Limit: None megabytes Problem Description: In a medieval kingdom, the economic crisis is raging. Milk drops fall, Economic indicators are deteriorating every day, money from the treasury disappear. To remedy the situation, King Charles Sunnyface decided make his...
1,983
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: Let's introduce the designation , where *x* is a string, *n* is a positive integer and operation "<=+<=" is the string concatenation operation. For example, [*abc*,<=2]<==<=*abcabc*. We'll say that string *s* can be obtained from...
1,984
Title: Triangle Time Limit: None seconds Memory Limit: None megabytes Problem Description: There is a right triangle with legs of length *a* and *b*. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the v...
1,985
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: As we know, DZY loves playing games. One day DZY decided to play with a *n*<=Γ—<=*m* matrix. To be more precise, he decided to modify the matrix with exactly *k* operations. Each modification is one of the following: 1. Pick som...
1,986
Title: Routine Problem Time Limit: None seconds Memory Limit: None megabytes Problem Description: Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio *a*:*b*. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio *c*:*d*. Manao adjusts the view...
1,987
Title: Chain Reaction Time Limit: None seconds Memory Limit: None megabytes Problem Description: Group of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a pl...
1,988
Title: Subsequences Return Time Limit: None seconds Memory Limit: None megabytes Problem Description: Assume that *s**k*(*n*) equals the sum of digits of number *n* in the *k*-based notation. For example, *s*2(5)<==<=*s*2(1012)<==<=1<=+<=0<=+<=1<==<=2, *s*3(14)<==<=*s*3(1123)<==<=1<=+<=1<=+<=2<==<=4. The sequence o...
1,989
Title: Castle Time Limit: 2 seconds Memory Limit: 256 megabytes Problem Description: Gerald is positioned in an old castle which consists of *n* halls connected with *n*<=-<=1 corridors. It is exactly one way to go from any hall to any other one. Thus, the graph is a tree. Initially, at the moment of time 0, Gerald ...
1,990
Title: Mike and Feet Time Limit: None seconds Memory Limit: None megabytes Problem Description: Mike is the president of country What-The-Fatherland. There are *n* bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to *n* from left to right. *i*-th bear is exac...
1,991
Title: Shifting Time Limit: None seconds Memory Limit: None megabytes Problem Description: John Doe has found the beautiful permutation formula. Let's take permutation *p*<==<=*p*1,<=*p*2,<=...,<=*p**n*. Let's define transformation *f* of this permutation: where *k* (*k*<=&gt;<=1) is an integer, the transformatio...
1,992
Title: none Time Limit: None seconds Memory Limit: None megabytes Problem Description: A widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called "Guess That Car!". The game show takes place on a gi...
1,993
Title: Seating On Bus Time Limit: None seconds Memory Limit: None megabytes Problem Description: Consider 2*n* rows of the seats in a bus. *n* rows of the seats on the left and *n* rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4*n*. Consider that *m* (*m*<...
1,994
Title: The Way to Home Time Limit: None seconds Memory Limit: None megabytes Problem Description: A frog lives on the axis *Ox* and needs to reach home which is in the point *n*. She starts from the point 1. The frog can jump to the right at a distance not more than *d*. So, after she jumped from the point *x* she c...
1,995
Title: New Year Table Time Limit: None seconds Memory Limit: None megabytes Problem Description: Gerald is setting the New Year table. The table has the form of a circle; its radius equals *R*. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider al...
1,996
Title: Inna and Dima Time Limit: None seconds Memory Limit: None megabytes Problem Description: Inna and Dima bought a table of size *n*<=Γ—<=*m* in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A". Inna loves Dima, so she wants to go through his name as many times as possible as she mov...
1,997
Title: Interesting drink Time Limit: None seconds Memory Limit: None megabytes Problem Description: Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known tha...
1,998
Title: Tree Constructing Time Limit: None seconds Memory Limit: None megabytes Problem Description: You are given three integers $n$, $d$ and $k$. Your task is to construct an undirected tree on $n$ vertices with diameter $d$ and degree of each vertex at most $k$, or say that it is impossible. An undirected tree i...
1,999