task stringlengths 0 154k | __index_level_0__ int64 0 39.2k |
|---|---|
At the entrance examination for the magistracy of the MSU Cyber-Mechanics Department Sasha got the question about Ford-Fulkerson algorithm. He knew the topic perfectly as he worked with it many times on programming competition. As the task for the question he was given a network with partially build flow that he had to... | 24,800 |
There are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided to make a table T showing the magnitude relationship between them. T has N Γ N elements, and each el... | 24,801 |
The three dice brothers are triplets, one and the same, and three can be said to be one. Since they are triplets, they are indistinguishably similar. Such three dice brothers are A's favorite toys. Mr. A is always playing with rolling dice in a set of three. As you can see, A is a toy that he enjoys playing, but in fac... | 24,802 |
Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the "Shift" key on standard keyboards, that is, they make ... | 24,803 |
All of us know that girls in Arpaβs land are... ok, youβve got the idea :D
Anyone knows that Arpa isn't a normal man, he is ... well, sorry, I can't explain it more. Mehrdad is interested about the reason, so he asked Sipa, one of the best biology scientists in Arpa's land, for help. Sipa has a DNA editor.
<image>
S... | 24,804 |
You are given a string s, consisting only of characters '0' or '1'. Let |s| be the length of s.
You are asked to choose some integer k (k > 0) and find a sequence a of length k such that:
* 1 β€ a_1 < a_2 < ... < a_k β€ |s|;
* a_{i-1} + 1 < a_i for all i from 2 to k.
The characters at positions a_1, a_2, ...,... | 24,805 |
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) Γ (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traff... | 24,806 |
You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 24,807 |
You are given an undirected graph, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it.
Let's call a triple (u, v, s) interesting, if 1 β€ u < v β€ n and there is a path (possibly non-simple, i.e. it can visit the same vertices and edges multiple times) between verti... | 24,808 |
The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.
The Galaxy contains N planets, connected by bidirectional hyperspace tunnels i... | 24,809 |
There are three airports A, B and C, and flights between each pair of airports in both directions.
A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.
Consider a route where we start at one of th... | 24,810 |
Your friend recently gave you some slimes for your birthday. You have a very large amount of slimes with value 1 and 2, and you decide to invent a game using these slimes.
You initialize a row with n empty spaces. You also choose a number p to be used in the game. Then, you will perform the following steps while the l... | 24,811 |
Ito joined the Kyudo club after entering high school. At first, I had a hard time because the arrow didn't reach the target, but in the fall of my first year of high school, I managed to improve to the point where the arrow reached the target.
One day, my senior Kato suggested, "Why don't you participate in a recent K... | 24,812 |
Snuke has a string x of length N. Initially, every character in x is `0`.
Snuke can do the following two operations any number of times in any order:
* Choose A consecutive characters in x and replace each of them with `0`.
* Choose B consecutive characters in x and replace each of them with `1`.
Find the number o... | 24,813 |
Given 'n', print the symbol 'Z' spanning n rows using '*' symbol.
Value of n>2 and n β€ 20.
Example:
1) Input : n=3
Output:
***
*
***
2) Input n=4
Output:
****
*
*
****
SAMPLE INPUT
5
SAMPLE OUTPUT
*****
*
*
*
*****
Explanation
The 'Z' is printed across 5 lines as shown above. | 24,814 |
Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.
Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.
Snuke wants to create the maximum number of pairs from his card... | 24,815 |
You are working for the Gryzzl company, headquartered in Pawnee, Indiana.
The new national park has been opened near Pawnee recently and you are to implement a geolocation system, so people won't get lost. The concept you developed is innovative and minimalistic. There will be n antennas located somewhere in the park.... | 24,816 |
You are given n distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing.
You consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print the answer modulo 109 + 7.... | 24,817 |
There are 2N points evenly spaced on the circumference of a circle. These points are numbered 1 to 2N in clockwise order, starting from some of them.
Snuke will divide these points into N pairs, then for each pair, he will draw a line segment connecting the two points. After the line segments are drawn, two points are... | 24,818 |
There are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies.
Snuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations:
1. Choose a pile with the largest n... | 24,819 |
Let f(x) = a0 + a1x + a2x2 + ... + adxd be the function where each ai (0 β€ i β€ d) is a constant integer (and ad is non-zero) and x is a variable. Your task is to write a program that finds all complex integer solutions of the equation f(x) = 0 for a given f(x). Here, by complex integers, we mean complex numbers whose r... | 24,820 |
X and A are integers between 0 and 9 (inclusive).
If X is less than A, print 0; if X is not less than A, print 10.
Constraints
* 0 \leq X, A \leq 9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X A
Output
If X is less than A, print 0; if X is not less th... | 24,821 |
Will shares a psychic connection with the Upside Down Monster, so everything the monster knows, Will knows. Suddenly, he started drawing, page after page, non-stop. Joyce, his mom, and Chief Hopper put the drawings together, and they realized, it's a labeled tree!
<image>
A tree is a connected acyclic graph. Will's t... | 24,822 |
Limak is a little polar bear. He likes nice strings β strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as t... | 24,823 |
Barney is searching for his dream girl. He lives in NYC. NYC has n junctions numbered from 1 to n and n - 1 roads connecting them. We will consider the NYC as a rooted tree with root being junction 1. m girls live in NYC, i-th of them lives along junction ci and her weight initially equals i pounds.
<image>
Barney co... | 24,824 |
You are given non-negative integer N. Find N pairwise different points on the Euclidean plane with integer coordinates in the corresponding order and the following properties:
1) the distance between any two consecutive points in the order is equal for the all pairs of consecutive points 2) the angle created by any t... | 24,825 |
We have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as follows:
* First, write 0 in every square.
* For each i=1,2,...,N, choose an integer k_i (0\leq k_i\leq M), and add 1 to each of the leftmost k_i squares in the i-th row.
* For each j=1,2,...,M, choose an intege... | 24,826 |
One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won.
Alex has grown up since then, so he easily wins the most difficu... | 24,827 |
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the socia... | 24,828 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,... | 24,829 |
There are N points in a D-dimensional space.
The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).
The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}.
How many pairs (i, j) (i < j) are there such ... | 24,830 |
n heroes fight against each other in the Arena. Initially, the i-th hero has level a_i.
Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).
When two heroes of equal levels fight,... | 24,831 |
Greg has an array a = a1, a2, ..., an and m operations. Each operation looks as: li, ri, di, (1 β€ li β€ ri β€ n). To apply operation i to the array means to increase all array elements with numbers li, li + 1, ..., ri by value di.
Greg wrote down k queries on a piece of paper. Each query has the following form: xi, yi, ... | 24,832 |
A daily train consists of N cars. Let's consider one particular car. It has 54 places numbered consecutively from 1 to 54, some of which are already booked and some are still free. The places are numbered in the following fashion:
The car is separated into 9 compartments of 6 places each, as shown in the picture. So, ... | 24,833 |
Salem gave you n sticks with integer positive lengths a_1, a_2, β¦, a_n.
For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from a to b is |a - b|, where |x| means the absolute value of x.
A stick length a_i is... | 24,834 |
Due to the recent popularity of the Deep learning new countries are starting to look like Neural Networks. That is, the countries are being built deep with many layers, each layer possibly having many cities. They also have one entry, and one exit point.
There are exactly L layers, each having N cities. Let us look at... | 24,835 |
Write a program which reads an integer and prints sum of its digits.
Input
The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000.
The input ends with a line including single zero. Your program should not process for this terminal ... | 24,836 |
Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly 1 problem, during the second day β exactly 2 problems, during the third day β exactly 3 problems, and so on. During the k-th day he should solve k problems.
Polycarp has a list of n contests, th... | 24,837 |
On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay from 0 to 9 peas. The pawn wants to reach the uppermost row having c... | 24,838 |
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.
You have to find minimum k such that there exists at least one k-dominant character.
Input
The first line contains string s consisting of lowercas... | 24,839 |
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543)
You are given a directed acyclic graph G with n vertices and m edges. Denote by R(v) the set of all vertices u reachable from v by moving along the edges of G. Find β_... | 24,840 |
There is a square grid with N rows and M columns. Each square contains an integer: 0 or 1. The square at the i-th row from the top and the j-th column from the left contains a_{ij}.
Among the 2^{N+M} possible pairs of a subset A of the rows and a subset B of the columns, find the number of the pairs that satisfy the f... | 24,841 |
A biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and each subsequent multiple of A seconds after activation.
Find the total number of biscuits produced within T + 0.5 seconds after activation.
Constraints
* All values in input are integers.
* 1 \leq A, B, T \le... | 24,842 |
Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!).
Let us remind you the rules of this game. Rock-paper-scissors is played by two players. In each round the players choose one of three items independently from each other. They show the items with their hands: a rock, scisso... | 24,843 |
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp.
What maximum value of function m(a) can Serej... | 24,844 |
Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.
You are a new applicant for his company. Boboniu will test you with the following chess question:
Consider a nΓ m grid (rows are numbered from 1 to n, and columns are nu... | 24,845 |
Given is a positive integer N.
Find the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:
* When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.
Con... | 24,846 |
Little X has met the following problem recently.
Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>
Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the foll... | 24,847 |
You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for example, the string s=";;" contains three empty words separated by ';'.
You ... | 24,848 |
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer that increases when you use this skill. Different character classes... | 24,849 |
A group of students has recently been admitted to the Faculty of Computer Sciences at the Berland State University. Now the programming teacher wants to divide them into three subgroups for practice sessions.
The teacher knows that a lot of programmers argue which language is the best. The teacher doesn't want to hear... | 24,850 |
At the children's festival, children were dancing in a circle. When music stopped playing, the children were still standing in a circle. Then Lena remembered, that her parents gave her a candy box with exactly k candies "Wilky May". Lena is not a greedy person, so she decided to present all her candies to her friends i... | 24,851 |
Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. Also, if there are multiple answers, only the first answer found will be ou... | 24,852 |
There are N people. The name of the i-th person is S_i.
We would like to choose three people so that the following conditions are met:
* The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`.
* There are no multiple people whose names begin with the same letter.
How many such ways are there to choo... | 24,853 |
Mishka got an integer array a of length n as a birthday present (what a surprise!).
Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps:
* Replace each occurre... | 24,854 |
You have to handle a very complex water distribution system. The system consists of n junctions and m pipes, i-th pipe connects junctions x_i and y_i.
The only thing you can do is adjusting the pipes. You have to choose m integer numbers f_1, f_2, ..., f_m and use them as pipe settings. i-th pipe will distribute f_i u... | 24,855 |
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for a rubles, a pack of two copybooks for b rubles, and a pack of t... | 24,856 |
Example
Input
6 6
3
1
9
4
3
6
1 2
1 4
2 6
5 4
6 5
3 2
Output
17 | 24,857 |
Consider the following set of rules for encoding strings consisting of `0` and `1`:
* Strings `0` and `1` can be encoded as `0` and `1`, respectively.
* If strings A and B can be encoded as P and Q, respectively, then string AB can be encoded as PQ.
* If string A can be encoded as P and K \geq 2 is a positive integer,... | 24,858 |
If the strings are consecutive, you can replace the characters with a rule to shorten the string. For example, for the string AAAA, the expression @ 4A will compress one character. Create a program that restores the character string compressed by this rule to the original character string. However, it is assumed that t... | 24,859 |
You have a string s β a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:
* 'W' β move one cell up;
* 'S' β move one cell down;
* 'A' β move one cell left;
* 'D' β move one cell right.
Let Grid(s) be the grid of minimum possibl... | 24,860 |
Ivan Anatolyevich's agency is starting to become famous in the town.
They have already ordered and made n TV commercial videos. Each video is made in a special way: the colors and the soundtrack are adjusted to the time of the day and the viewers' mood. That's why the i-th video can only be shown within the time rang... | 24,861 |
You are given array a of length n. You can choose one segment [l, r] (1 β€ l β€ r β€ n) and integer value k (positive, negative or even zero) and change a_l, a_{l + 1}, ..., a_r by k each (i.e. a_i := a_i + k for each l β€ i β€ r).
What is the maximum possible number of elements with value c that can be obtained after one ... | 24,862 |
You have an array a consisting of n integers. Each integer from 1 to n appears exactly once in this array.
For some indices i (1 β€ i β€ n - 1) it is possible to swap i-th element with (i + 1)-th, for other indices it is not possible. You may perform any number of swapping operations any order. There is no limit on the ... | 24,863 |
Let us define a magic grid to be a square matrix of integers of size n Γ n, satisfying the following conditions.
* All integers from 0 to (n^2 - 1) inclusive appear in the matrix exactly once.
* [Bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all elements in a row or a column must be the sa... | 24,864 |
Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".
Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowe... | 24,865 |
Niwango bought a piece of land that can be represented as a half-open interval [0, X).
Niwango will lay out N vinyl sheets on this land. The sheets are numbered 1,2, \ldots, N, and they are distinguishable. For Sheet i, he can choose an integer j such that 0 \leq j \leq X - L_i and cover [j, j + L_i) with this sheet.
... | 24,866 |
Arnab is given a string, but being the evil Lord he is, he has his own whims and fantasies about the string he wants to keep with himself. If he can convert a string into a palindrome by rearranging the characters, he will keep that string, otherwise he will discard that string. Youβve to tell if Arnab will keep that s... | 24,867 |
The Little Elephant from the Zoo of Lviv has an array A that consists of N positive integers. Let A[i] be the i-th number in this array (i = 1, 2, ..., N).
Find the minimal number x > 1 such that x is a divisor of all integers from array A. More formally, this x should satisfy the following relations:
A[1] mod x = 0... | 24,868 |
The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills.
The boy is now looking at the ratings of consecutive participan... | 24,869 |
Every person likes prime numbers. Alice is a person, thus she also shares the love for them. Bob wanted to give her an affectionate gift but couldn't think of anything inventive. Hence, he will be giving her a graph. How original, Bob! Alice will surely be thrilled!
When building the graph, he needs four conditions to... | 24,870 |
Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:
\begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*}
Constraints
... | 24,871 |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed.
If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.
N people will pus... | 24,872 |
Apple adventure
square1001 and E869120 got lost in the grid world of $ H $ rows and $ W $ rows!
Said the god of this world.
"When you collect $ K $ apples and they meet, you'll be back in the original world."
Upon hearing this word, square1001 decided to collect more than $ K $ of apples and head to the square wher... | 24,873 |
There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.
Each kangaroo can hold at most one kangaroo, and the kangaroo who is ... | 24,874 |
After setting up the area. Chandu wanted all his toys to be stacked there in that area. So that all of them are accessible easily. Currently, He is having N stacks of toys each with height H_1,H_2...H_n (assuming all toys are of same height).Chandu did not like the configuration much and want to change the height of ea... | 24,875 |
Yaroslav has an array p = p1, p2, ..., pn (1 β€ pi β€ n), consisting of n distinct integers. Also, he has m queries:
* Query number i is represented as a pair of integers li, ri (1 β€ li β€ ri β€ n).
* The answer to the query li, ri is the number of pairs of integers q, w (li β€ q, w β€ ri) such that pq is the divisor o... | 24,876 |
Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria.
1. first by $x$-coordinate
2. in case of a tie, by $y$-coordinate
Constraints
* $1 \leq n \leq 100,000$
* $-1,000,000,000 \leq x_i, y_i \leq 1,000,000,000$
Input
The input is given in the following form... | 24,877 |
Boolean Expression Compressor
You are asked to build a compressor for Boolean expressions that transforms expressions to the shortest form keeping their meaning.
The grammar of the Boolean expressions has terminals `0` `1` `a` `b` `c` `d` `-` `^` `*` `(` `)`, start symbol <E> and the following production rule:
> <E>... | 24,878 |
You are given three positive (i.e. strictly greater than zero) integers x, y and z.
Your task is to find positive integers a, b and c such that x = max(a, b), y = max(a, c) and z = max(b, c), or determine that it is impossible to find such a, b and c.
You have to answer t independent test cases. Print required a, b a... | 24,879 |
A little girl loves problems on trees very much. Here's one of them.
A tree is an undirected connected graph, not containing cycles. The degree of node x in the tree is the number of nodes y of the tree, such that each of them is connected with node x by some edge of the tree.
Let's consider a tree that consists of ... | 24,880 |
You are given two integers l and r in binary representation. Let g(x, y) be equal to the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all integers from x to y inclusive (that is x β (x+1) β ... β (y-1) β y). Let's define f(l, r) as the maximum of all values of g(x, y) satisfying l β€ x β€ y β€ r.
... | 24,881 |
Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game!
n racers take part in the championship, which consists of a number of races. After each race racers are a... | 24,882 |
Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stone... | 24,883 |
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
Constraints
* 1\leq N \leq 10^{16}
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the maximum possible sum of the digits (in base 10) of a positive integer not... | 24,884 |
Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.
In this problem you should implement the similar functionality.
You are given a string which only consists of:
* uppercase and lowercase English... | 24,885 |
When
displaying a collection of rectangular windows, a critical step is determining
whether two windows overlap, and, if so, where on the screen the overlapping
region lies. Write a program to perform this function. Your program will accept
as input the coordinates of two rectangular... | 24,886 |
Polycarp knows that if the sum of the digits of a number is divisible by 3, then the number itself is divisible by 3. He assumes that the numbers, the sum of the digits of which is divisible by 4, are also somewhat interesting. Thus, he considers a positive integer n interesting if its sum of digits is divisible by 4.
... | 24,887 |
Problem Statement
One day, you found an old scroll with strange texts on it.
You revealed that the text was actually an expression denoting the position of treasure. The expression consists of following three operations:
* From two points, yield a line on which the points lie.
* From a point and a line, yield a poin... | 24,888 |
Let n be an integer. Consider all permutations on integers 1 to n in lexicographic order, and concatenate them into one big sequence p. For example, if n = 3, then p = [1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, 3, 2, 1]. The length of this sequence will be n β
n!.
Let 1 β€ i β€ j β€ n β
n! be a pair of indices. We cal... | 24,889 |
Vasya and Petya take part in a Codeforces round. The round lasts for two hours and contains five problems.
For this round the dynamic problem scoring is used. If you were lucky not to participate in any Codeforces round with dynamic problem scoring, here is what it means. The maximum point value of the problem depends... | 24,890 |
Let's assume that p and q are strings of positive length, called the container and the key correspondingly, string q only consists of characters 0 and 1. Let's take a look at a simple algorithm that extracts message s from the given container p:
i = 0;
j = 0;
s = <>;
while i is le... | 24,891 |
Sunuke received a d-dimensional hypercube with a side length of l1 Γ ... Γ ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and ate the part that satisfied x1 + ... + xd β€ s. However, xi represents the i-th coordinate. If the ... | 24,892 |
One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts. Some parts were painted red and all the other were painted blue. Besides,... | 24,893 |
There is a frog known as "CHAMELEON" because he has a special feature to change its body's color similar to stone's color on which he sits. There are N colorful stones lying in a row, but of only 1 to 100 different colors. Frog can hopp on another stone if the stone has same color as its body or (i-1)th stone if it is ... | 24,894 |
We will call a string that can be obtained by concatenating two equal strings an even string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.
You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by delet... | 24,895 |
You are given an array a_1, a_2, β¦, a_n of integers. This array is non-increasing.
Let's consider a line with n shops. The shops are numbered with integers from 1 to n from left to right. The cost of a meal in the i-th shop is equal to a_i.
You should process q queries of two types:
* 1 x y: for each shop 1 β€ i β€ ... | 24,896 |
Fangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing n characters (which is the size of one text message). Thus, whole sentences and words get split!
Fangy did not like ... | 24,897 |
Cold winter evenings in Tomsk are very boring β nobody wants be on the streets at such a time. Residents of Tomsk while away the time sitting in warm apartments, inventing a lot of different games. One of such games is 'Colored Jenga'.
This game requires wooden blocks of three colors: red, green and blue. A tower of n... | 24,898 |
There is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain.
Each colony arrangement can be expressed as a string of even length, where the i-th character of the string represents the type of villain in the i-th hole.
Iron Man can destroy a colony only if the colon... | 24,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.