task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Window (WINDOW1) We have a polygon chosen in the cartesian coordinate system. Sides of the polygon are parallel to the axes of coordinates. Every two consecutive sides are perpendicular and coordinates of every vertex are integers. We have also given a window that is a rectangle whose sides are parallel to the axes of...
30,800
Assembler circuits (ASCIRC) Bytetel Company decided to improve computers they produce. They want to replace assembler programs with special systems called assembler circuits. Assembler programs consist solely of assignments. Each assignment is determined by four elements: two registers from which data are taken,...
30,801
Automatic Teller Machines (ATMS) Every member of Byteland Credit Society is entitled to loan any amount of Bytelandish ducats unless it is 10 30 or more, but he has to return the whole amount within seven days. There are 100 ATMs in the Client Service Room of the Society. They are numbered from 0 to 99. Every ATM can...
30,802
Chase (CHASE1) Chase is a two-person board game. A board consists of squares numbered from 1 to n . For each pair of different squares it is known if they are adjacent to one another or they are not. Each player has a piece at his disposal. At the beginning of a game pieces of players are placed on fixed, distinct sq...
30,803
The lightest language (LITELANG) Alphabet A k consists of k initial letters of English alphabet. A positive integer called a weight is assigned to each letter of the alphabet. A weight of a word built from the letters of the alphabet A k is the sum of weights of all letters in this word. A language over an alpha...
30,804
Flat broken lines (FLBRKLIN) We have a cartesian coordinate system drawn on a sheet of paper. Let us consider broken lines that can be drawn with a single pencil stroke from the left to the right side of the sheet. We also require that for each segment of the line the angle between the straight line containing this se...
30,805
Rectangles (RECTNG1) There are n rectangles drawn on the plane. Each rectangle has sides parallel to the coordinate axes and integer coordinates of vertices. We define a block as follows: each rectangle is a block, if two distinct blocks have a common segment then they form the new block otherwise we sa...
30,806
Musketeers (MUSKET) In the time of Louis XIII and his powerful minister cardinal Richelieu in the Full Barrel Inn n musketeers had consumed their meal and were drinking wine. Wine had not run short and therefore the musketeers were eager to quarrel, a drunken brawl broke out, in which each musketeer insulted all ...
30,807
Empty Cuboids (EMPTY) We call a cuboid regular if: one of its vertices is a point with coordinates (0, 0, 0), edges beginning in this vertex lie on the positive semi-axes of the coordinate system, the edges are not longer than 10 6 There is given a set A of points of space, whose coordinate...
30,808
Monodigital Representations (MONODIG) Let K be a decimal digit different from 0 . We say that an arithmetic expression is a K-representation of the integer X if a value of this expression is X and if it contains only numbers composed of a digit K. (All the numbers are of course decimal). The following arith...
30,809
The Game of Polygons (POLYGAME) Two players take part in the game polygons . A convex polygon with n vertices divided by n-3 diagonals into n-2 triangles is necessary. These diagonals may intersect in vertices of the polygon only. One of the triangles is black and the remaining ones are white. Players pro...
30,810
Rockets (ROCKETS) There are two separate, n -element sets of points of a two dimensional map: R and W . None triple of points from the set R ∪ W is collinear. Rockets earth-to-earth are located on points from the set R . Enemy objects, which should be destroyed, are located on points from the set W . The roc...
30,811
Potholers (POTHOLE) A team of speleologists organizes a training in the Great Cave of Byte Mountains. During the training each speleologist explores a route from Top Chamber to Bottom Chamber. The speleologists may move down only, i.e. the level of every consecutive chamber on a route should be lower then the previ...
30,812
Sleepwalker (SLEEP) There is a building with flat square roof of size 3 k *3 k and sides parallel to north-south and east-west directions. The roof is covered with square tiles of size 1 (with a side of length 1), but one of the tiles has been removed and there is a hole in the roof (big enough to fall in). The...
30,813
Icerink (ICERINK) A skating competition was organized on the largest icerink in Byteland. The icerink is a square of size 10000 * 10000. A competitor begins skating at the START point chosen by referees and his task is to finish sliding at the FINISH point, also chosen by referees. The points of START and FINISH ar...
30,814
Bitmap (BITMAP) There is given a rectangular bitmap of size n*m . Each pixel of the bitmap is either white or black, but at least one is white. The pixel in i -th line and j -th column is called the pixel ( i,j ). The distance between two pixels p 1 =( i 1 ,j 1 ) and p 2 =( i 2 ,j 2 ) is defined as: d(...
30,815
Three-coloring of binary trees (THREECOL) A tree consists of a node and some (zero, one or two) subtrees connected to it. These subtrees are called children. A specification of the tree is a sequence of digits. If the number of children in the tree is: zero, then the specification is a sequence with only o...
30,816
Store-keeper (STORE) The floor of a store is a rectangle divided into n × m square fields. Two fields are adjacent, if they have a common side. A parcel lays on one of the fields. Each of the remaining fields is either empty, or occupied by a case, which is too heavy to be moved by a store-keeper. The store-kee...
30,817
The Map (MAP) After a new administrative division of Byteland cartographic office works on a new demographic map of the country. Because of technical reasons only a few colors can be used. The map should be colored so that regions with the same or similar population (number of inhabitants) have the same color. For ...
30,818
The Altars (ALTARS) According to Chinese folk beliefs evil spirits can move only on a straight line. It is of a great importance when temples are built. The temples are constructed on rectangular planes with sides parallel to the north - south or east - west directions. No two of the rectangles have common points...
30,819
Primitivus recurencis (PRIMIT) A genetic code of the abstract primitivus ( Primitivus recurencis ) is a series of natural numbers K = ( a 1 ... a n ). A feature of primitivus we call each ordered pair of numbers ( l , r ), which appears successively in the genetic code, i.e. there exists such i that l...
30,820
Water among Cubes (WATER) On a rectangular mesh comprising n*m fields, n*m cuboids were put, one cuboid on each field. A base of each cuboid covers one field and its surface equals to one square inch. Cuboids on adjacent fields adhere one to another so close that there are no gaps between them. A heavy rain ...
30,821
Panic in the Plazas (PANIC) Have you ever heard of the BBFO? The Bytelandian Bit-eating Fanatic Organisation regards itself as a collection of people with slightly unorthodox views on law and order in the world, and is regarded by others as the most wildly dangerous and unpredictable terrorist organisation which affli...
30,822
Soldiers on Parade (SOPARADE) Protocol is really weird in Byteland. For instance, it is required that, when presenting arms before an officer, soldiers should stand in a single row (at positions numbered from 1 to n ). Soldiers may have one of 4 possible ranks, distinguished by the number of squiggles on the epaulets...
30,823
Relevant Phrases of Annihilation (PHRASES) You are the King of Byteland. Your agents have just intercepted a batch of encrypted enemy messages concerning the date of the planned attack on your island. You immedietaly send for the Bytelandian Cryptographer, but he is currently busy eating popcorn and claims that he may...
30,824
Vonny and her dominos (VONNY) Vonny loves playing with dominos. And so she owns a standard set of dominos. A standard set of dominos consists of 28 pieces called bones, tiles or stones. Each bone is a rectangular tile with a line dividing its face into two square ends. Each square is labeled with a number between 0 an...
30,825
Jewelry and Fashion (JEWELS) You work for a small jewelers' company, renowned for the exquisite necklaces and multi-colored amber strings it produces. For the last three centuries, the sales of strings alone have been enough to keep business going without a hitch. Now however, the influence of fashion is greater than ...
30,826
Ordering the Soldiers (ORDERS) As you are probably well aware, in Byteland it is always the military officer's main worry to order his soldiers on parade correctly. In Bitland ordering soldiers is not really such a problem. If a platoon consists of n men, all of them have different rank (from 1 - lowest to n - highest...
30,827
Shamans (SHAMAN) In the far bare land there lives a mysterious tribe. They suffer from drought every year but they stick to their faith in god that they will never leave their home land. To counter the dry weather the shamans in the tribe must pray during the hard time and hope the blessed rain will aid their producti...
30,828
Sorting is easy (SORTING) Do you think sorting is easy? try your luck in brainfuck   For those who don't know that brainfuck is a programming language: Take a look at the converter to C . It will ignore every unknown command, therefore submitting a program in any other language won't necessarily lead to compil...
30,829
The Zebra Crossing (ZEBRA) Have you ever wondered why people collide with each other at pedestrian crossings? The reasons are probably difficult to analyse from a scientific point of view, but we can hazard a guess. A part of the problem seems to be that the statistical pedestrian, when faced with a red light, will ei...
30,830
Getting Rid of the Holidays (Act I) (HOLIDAY1) King Johnny of Byteland has in his short period of sovereignty established quite a few national holidays (close on thirty, in fact) in honour of... more or less anything he could think of. Each of these holidays occurs every a fixed number of days (possibly different for ...
30,831
Very Fast Multiplication (VFMUL) Multiply the given numbers. Input n [the number of multiplications <= 101] l1 l2 [numbers to multiply (at most 300000 decimal digits each)] Text grouped in [ ] does not appear in the input file. Output The results of multiplications. Example Input: 5 4 2 123 43 32...
30,832
Converting number formats (ROMAN) Given the number n of test cases, convert n positive integers less than 2^32 (given one per line) from one representation to another. For convenience, n is given in the same format as the other numbers. Input Input is given by spelling the number in english digits (all upper ...
30,833
Sums in a Triangle (SUMITR) Let us consider a triangle of numbers in which a number appears in the first line, two numbers appear in the second line etc. Develop a program which will compute the largest of the sums of numbers that appear on the paths starting from the top towards the base, so that: on each pa...
30,834
Getting Rid of the Holidays (Act II) (HOLIDAY2) As King Johnny's temporary indisposition lengthens from days to weeks, and you still hold the office of Regent of Byteland, you begin to feel that acting king is not all that much fun. You encounter various absurdly weird problems. For instance, you find that contrary to...
30,835
Tour de Byteland (BTOUR) As the mayor of Byteland's term of office draws to a close, he starts his preparations for reelection. For the first time in the 40 years of his political career his chances of victory seem somewhat uncertain. His main cause of worry are the disturbing results of an opinion poll which state th...
30,836
Arranging the Blocks (BLOCKS) A group of n children are playing with a set of n 2 flat square blocks. Each block is painted from above with one colour, and there are no more than 2 blocks of each colour. The blocks are initially arranged in an n x n square forming some sort of picture. The children have been pr...
30,837
Stable Marriage Problem (STABLEMP) There are given n men and n women. Each woman ranks all men in order of her preference (her first choice, her second choice, and so on). Similarly, each man sorts all women according to his preference. The goal is to arrange n marriages in such a way that if a man m prefers s...
30,838
Square Root (SQRROOT) In this problem you have to find the Square Root for given number. You may assume that such a number exist and it will be always an integer. Solutions to this problem can be submitted in C, C++, Pascal, Algol, Fortran, Ada, Ocaml, Prolog, Whitespace, Brainf**k and Intercal only. Inp...
30,839
Chocolate (CHOCOLA) We are given a bar of chocolate composed of m × n square pieces. One should break the chocolate into single squares. Parts of the chocolate may be broken along the vertical and horizontal lines as indicated by the broken lines in the picture. A single break of a part of the chocolate along a c...
30,840
Containers (CTAIN) We are given n containers, where 1 <= n <= 4. At the beginning all of them are full of water. The liter capacity of the i -th container is a natural number o i satisfying inequalities 1 <= o i <= 49.  Three kinds of moves can be made:   Pou...
30,841
Triangle Partitioning (TRIPART) A triangle can be divided into two equal triangles by drawing a median on its largest edge (in the figure below such a division is shown with the red line). Then the smaller two triangles can be divided in similar fashion into equal triangles (shown in the picture below with blue lines)...
30,842
Connections (CONNECT) Byteotian Ministry of Infrastructure has decided to create a computer program that helps to find quickly the lengths of routes between arbitrary towns. It would be small wonder if the inhabitants of Byteotia always wanted to find the shortest route. However, it happens that they want to know t...
30,843
Period (PERIOD) For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 <= i <= N ) we want to know the largest K > 1 (if there is one) such that the prefix of S ...
30,844
Corporative Network (CORNET) A very big corporation is developing its corporate network. At the beginning, each of the N enterprises of the corporation, numbered from 1 to N , organized its own computing and telecommunication center. Soon, for amelioration of the services, the corporation started to collect some en...
30,845
Cave Exploration (CAVE) A long time ago one man said that he had explored the corridors of one cave. This means that he was in all corridors of the cave. Corridors are really horizontal or vertical segments. A corridor is treated as visited if he was in at least one point of the corridor. Now you want to know if thi...
30,846
Johnny and the Watermelon Plantation (WMELON) Shortly after his abdication from the Bytelandian throne Johnny decided to go into farming. Water melons were a natural choice as his first crop ever, since they seemed easy enough to grow and look after. So, he sold all his beer bottles and for the money he purchased a 1k...
30,847
The Water Ringroad (WATERWAY) There is a land far, far away were the entire population dwells in walled cities at the peaks of mountains on the circumference of a plateau known as The Circle. The High Councillors of the cities developed an intricate system of communication: the cities were connected into a cycle by a ...
30,848
City Game (CTGAME) Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees, factories and buildings. There is still some space in the area that is unoccupied. The strategic task of his game is to w...
30,849
Bicycle (BICYCLE) Peter likes to go to school by bicycle. But going by bicycle on sidewalks is forbidden and going along roads is dangerous. That's why Peter travels only along special bicycle lanes. Fortunately Peter's home and school are in the immediate proximity of such paths. In the city where Peter lives there a...
30,850
Interesting number (INUMBER) For the given number n find the minimal positive integer divisable by n , with the sum of digits equal to n . Input t – the number of test cases, then t test cases follow. (t <= 50) Test case description: n - integer such that 0 < n <= 1000 Output For each test ca...
30,851
Lifts (LIFTS) Serj likes old games very much. Recently he has found one arcade game in his computer. When controlling the hero it is necessary to move on a map and collect various items. At a certain stage of the game Serj has faced an unexpected problem. To continue his adventures the hero should get past over a chas...
30,852
Naptime (NAPTIME) Goneril is a very sleep-deprived cow. Her day is partitioned into N (3 ≤ N ≤ 3,830) equal time periods but she can spend only B (2 ≤ B < N) not necessarily contiguous periods in bed. Due to her bovine hormone levels, each period has its own utility U i (0 ≤ U i ≤ 200,000), which is the amount o...
30,853
Selfish Cities (SCITIES) Far, far away there is a world known as Selfishland because of the nature of its inhabitants. Hard times have forced the cities of Selfishland to exchange goods among each other. C1 cities are willing to sell some goods and the other C2 cities are willing to buy some goods (each city can eith...
30,854
Smart Network Administrator (NETADMIN) The citizens of a small village are tired of being the only inhabitants around without a connection to the Internet. After nominating the future network administrator, his house was connected to the global network. All users that want to have access to the Internet must be connec...
30,855
Prime or Not (PON) Given the number, you are to answer the question: "Is it prime?" Solutions to this problem can be submitted in C, C++, Pascal, Perl, Python, Ruby, Lisp, Hask, Ocaml, Prolog, Whitespace, Brainf**k and Intercal only. Input t – the number of test cases, then t test cases follows. [t ≤ 500]...
30,856
Polynomial Equations (POLYEQ) You are given the polynomial F(x) as the sum of monomials. Each monomial has the form: [ coefficient *] x [^ degree ] or [ coefficient ], where coefficient and degree are integers such that -30000 <= coefficient <= 30000, 0 <= degree <= 6. The parameters given in [] can be ski...
30,857
Cube Root (CUBERT) Your task is to calculate the cube root of a given positive integer. We can not remember why exactly we need this, but it has something in common with a princess, a young peasant, kissing and half of a kingdom (a huge one, we can assure you). Write a program to solve this crucial task. Input T...
30,858
Alibaba (ALIBB) Alibaba the famous character of our childhood stories would like to be immortal in order to keep bringing happiness to children. In order to reach this status he needs to prove that he is still able to do some unusual things. There are n treasures, ( n <= 10000) each in a different place located alo...
30,859
Officers on the Beat (OFBEAT) In the Middle Ages the capital of Byteland was surrounded by stout walls to protect the citizens from intruders. The gates of the city were well guarded and the drawbridge was lifted for the night, and everyone felt pretty happy and secure. At least, for a while. With time the usual d...
30,860
Teamwork is Crucial (TWORK) In the late Middle Ages the University of Byteland was no different than any other university of the day. One of those gloomy places where philosophers brooded over the essence of life, theologians did likewise and quaralled with philosophers, while alchemists developed new caustic types of...
30,861
Aggressive cows (AGGRCOW) Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1 ... xN (0 <= xi <= 1,000,000,000). His C (2 <= C <= N) cows don't like this barn layout and become aggressive towards each other once put into a stall....
30,862
Cable TV Network (CABLETV) The interconnection of the relays in a cable TV network is bi-directional. The network is connected if there is at least one interconnection path between each pair of relays present in the network. Otherwise the network is disconnected. An empty network or a network with a single relay is co...
30,863
Booklets (BOOK) Bob has a difficult job. He must distribute advertising booklets for extra school activities in different schools. The booklets have different number of pages. Bob has a list with the number of pages of each booklet and the number of schools that he must visit. He has to distribute the booklets such th...
30,864
Count on Cantor (CANTON) One of the famous proofs of modern mathematics is Georg Cantor's demonstration that the set of rational numbers is enumerable. The proof works by using an explicit enumeration of rational numbers as shown in the diagram below. 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 3/1 3/2 3/3 4/1 4/2 ...
30,865
The Unstable Cube (UCUBE) A large cube (of size N×N×N) is given. At the beginning it consists of small blocks (1×1×1) and each block is painted in some color (different blocks may have the same color). But in the process of exploitation some blocks have disappeared. Given 6 photos of the unstable cube you have to calc...
30,866
The Room Pattern (RATTERN) It was decided to make a parquet floor in a room of size NxM. The idea is to lay out some pattern on the floor. The parquet tiles with which the floor of the room looks best consist of squares 1x1, each of which can be either white or black. The required color of each square of the room is s...
30,867
Pythagorean Legacy (PITPAIR) It is necessary to find a minimal integer value R which is equal to the length of the hypotenuse (the side opposite the right angle) of N non-identical rectangular triangles with integer lengths of sides. Input t - number of test cases [t ≤ 100], then t lines follow, each line contains...
30,868
The Tall Windmills (WINDMILL) In the later days of his career Johnny purchased a long and narrow strip of land on which he intended to erect a row of windmills, and live off the electrical energy produced by his little power plant. To his dismay, he soon discovered that he had been badly cheated - throughout most of t...
30,869
Platon and Socrates (PLATON) Platon and Socrates one day decided to play a new game. They asked their friend to think of two numbers between 1 and 5000, not equal. Then they asked him to tell the product to Platon and the sum to Socrates. After that they tried to figure out what these numbers are. They played a lot of...
30,870
Bishops (BISHOPS) Yesterday was Sam's birthday. The most interesting gift was definitely the chessboard. Sam quickly learned the rules of chess and defeated his father, all his friends, his little sister, and now no one wants to play with him any more. So he decided to play with another birthday gift – a Book of Mat...
30,871
Calls (CALLS) A young archeologist Senoj Anaidni recently made a very important discovery which will make him famous (or at least he thinks so). He found several scraps of paper resembling advertisement flyers of an ancient phone company. His research showed that modern phone companies follow a few basic rules to comp...
30,872
Hard Question (HARDQ) Students of computer science in Bratislava enjoy hiking and camping during their long summer breaks. They love walking silently in the groves, visiting sparkling waterfalls, exploring dark caves, climbing steep hills, or just sleeping in a tent. Some of them already visited all the national parks...
30,873
The Philosophical Dispute (PHDISP) One day, mathematician and philosopher were engaged in a heated dispute. Philosopher said: - Ideal line has only length and no width, therefore, no line can have an area. Mathematician replied: - That's as it may be, but still you can fill a square with a line in such a way...
30,874
Exchange Operations (EOPERA) Given a sequence of 12 numbers consisting of 0 and the first 11 natural numbers. Suppose number 0 is in the i-th position of the sequence (positions are numbered from 0 to 11). You can swap it with the number in the j-th position if the following conditions hold: | i – j | = d k , whe...
30,875
Roads (ROADS) English Vietnamese N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associated with it: the road length and the toll that needs to be paid for the road (expressed in the number of coins). Bob and Alice used to live in the city 1. After noticin...
30,876
Recursive Sequence (SEQ) Sequence (a i ) of natural numbers is defined as follows:    a i = b i (for i <= k )    a i = c 1 a i-1 + c 2 a i-2 + ... + c k a i-k (for i > k ) where b j and c j are given natural numbers for 1<=j<=k . Your task is to compute a n for given n and output it modulo 10...
30,877
Poker (POKER) In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest): royal flush - ace, king, queen, jack and ten, all in the same suit. straight flush - five cards of the same suit in sequence, such as 10, 9, 8, 7, 6 of clubs; ace can be counted both as the highest card or as th...
30,878
Mixtures (MIXTURES) Harry Potter has n mixtures in front of him, arranged in a row. Each mixture has one of 100 different colors (colors have numbers from 0 to 99). He wants to mix all these mixtures together. At each step, he is going to take two mixtures that stand next to each other and mix them together, a...
30,879
Bytelandian gold coins (COINS) In Byteland they have a very strange monetary system. Each Bytelandian gold coin has an integer number written on it. A coin n can be exchanged in a bank into three coins: n/2, n/3 and n/4. But these numbers are all rounded down (the banks have to make a profit). You can also...
30,880
Lazy Cows (LAZYCOWS) English Vietnamese Farmer John regrets having applied high-grade fertilizer to his pastures since the grass now grows so quickly that his cows no longer need to move around when they graze. As a result, the cows have grown quite large and lazy... and winter is approaching. Farmer Joh...
30,881
Expedition (EXPEDI) A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run over a rock and puncture the truck's fuel tank. The truck now leaks one unit of fuel every unit of distance it travels. To repair the truck, th...
30,882
Around the world (AROUND) Over the years, FJ has made a huge number of farmer friends all around the world. Since he hasn't visited 'Farmer Ted' from England and 'Boer Harms' from Holland for a while, he'd like to visit them. He knows the longitude of the farm where each of his worldwide friends resides. This lon...
30,883
Landscaping (LANDSCAP) Farmer John is making the difficult transition from raising mountain goats to raising cows. His farm, while ideal for mountain goats, is far too mountainous for cattle and thus needs to be flattened out a bit. Since flattening is an expensive operation, he wants to remove the smallest amoun...
30,884
Ha-noi! (HAN01) Little Sabrina loves solving puzzles. Last week she got a new puzzle: The "Tower of Hanoi" puzzle. This puzzle is based on an old legend: "The temple priests of Hanoi have to transfer a tower consisting of 64 fragile disks of gold from one part of the temple to another, one disk at a time. The disks a...
30,885
Alpha Centauri Tennis (ACT) As you may know, planets of Alpha Centauri (if they indeed do exist) would provide excellent conditions for intelligent life forms. It is indeed true that there is a small Earthlike planet near Alpha Centauri, inhabited by a population of no particular significance. These humanlike cre...
30,886
Ignore the Garbage (IGARB) Fred works as an IT consultant in an insurance company. As they always had a large amount of customers waiting and arguing at the front desk, management decided to deploy a ticket machine. Each customer would get a ticket with a number and there will be fancy LCD display over each desk showi...
30,887
Crane Operator (COPER) You are the operator of a crane. In the reach of the crane there are N locations numbered from 0 to N-1 . Initially the location 0 is empty and each of the other locations contains a box with the respective number (i.e. the box in the location i has the number i ). You were assigned ...
30,888
Pocket Money (LISA) Young people spend a lot of money on things like sweets, music CDs, mobile phones and so on. But most young girls/boys have one problem: Their pocket money is not enough for all these jolly things. Little Lisa Listig is one of these poor girls with a small pocket money budget. Last month her po...
30,889
Phidias (PHIDIAS) Famous ancient Greek sculptor Phidias is making preparations to build another marvellous monument. For this purpose he needs rectangular marble plates of sizes W1 x H1, W2 x H2 ... WN x HN. Recently, Phidias has received a large rectangular marble slab. He wants to cut the slab to obtain plates ...
30,890
Farmer (FARMER) A farmer has a set of fields, each of which is surrounded by cypress trees. Also, the farmer has a set of strips of land, each of which has a row of cypress trees. In both fields and strips, between every two consecutive cypress trees is a single olive tree. All of the farmer’s cypress trees either ...
30,891
Empodia (EMPODIA) The ancient mathematician and philosopher Pythagoras believed that reality is mathematical in nature. Present-day biologists study properties of biosequences. A biosequence is a sequence of M integers, which contains each of the numbers 0, 1 ... M - 1, starts with 0 and ends with M - 1, and ...
30,892
Cobbled streets (CSTREET) The municipal chronicals of an unbelievable lordly major town in a land far, far away tell the following story: Once upon a time the new crowned king Günther decided to visit all towns in his kingdom. The people of the unbelievable lordly major town expected that king Günther would like to s...
30,893
Math I (MATH1) You are given n integers a 1 , a 2 ... a n (0 ≤ a i ≤ n). The sum a 1 + a 2 + ... + a n does not exceeded n. Your task is to find n other integers x 1 , x 2 ... x n (note that x i may be negative numbers) satisfying the following conditions: (x i - x i+1 + a i+1 = 0) or (x i - x i+1 +...
30,894
Ones and zeros (ONEZERO) Certain positive integers have their decimal representation consisting only of ones and zeros, and having at least one digit one, e.g. 101. If a positive integer does not have such a property, one can try to multiply it by some positive integer to find out whether the product has this property...
30,895
Boxes (BOXES) English Vietnamese There are n boxes on the circle. The boxes are numbered from 1 to n (1<=n<=1000) in clock wise order. There are balls in the boxes, and the number of all the balls in the boxes is not greater than n. The balls should be displaced in such a way that in each box there remai...
30,896
The Benefactor (BENEFACT) Another chapter of the municipal chronicles of a well known unbelievable lordly major town (if this town is not well known to you, you might want to solve problem CSTREET first) tells us the following story: Once upon a time the citizens of the unbelievable lordly major town decided ...
30,897
Greedy island (GREED) Gon is on Greedy island. He wants to go home. But to get the ticket to leave the game, he has to get N cards labeled in a sequence from 1 to N (the order of the cards in his hand is irrelevant). He already has N cards, but not forming a sequence from 1 to N. So he wants you to help him. For some ...
30,898
Count maximum matrices (MATRIX) You are given a matrix A of M rows and N columns, consisting of numbers 0 and 1. For a rectangle in A (sides ≥ 1), X1 is the number of ones on its sides, X0 is the number of zeros on its sides, and its value is defined as X1 – X0. Let us consider W, the maximum value taken over submat...
30,899