text stringlengths 424 69.5k |
|---|
### Prompt
Create a solution in Cpp for the following problem:
Let's call a list of positive integers a_0, a_1, ..., a_{n-1} a power sequence if there is a positive integer c, so that for every 0 β€ i β€ n-1 then a_i = c^i.
Given a list of n positive integers a_0, a_1, ..., a_{n-1}, you are allowed to:
* Reorder th... |
### Prompt
Create a solution in CPP for the following problem:
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 station is at a distance of d m... |
### Prompt
In Cpp, your task is to solve the following problem:
Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right.
Once Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed t... |
### Prompt
Generate a Cpp solution to the following problem:
Miyako came to the flea kingdom with a ukulele. She became good friends with local flea residents and played beautiful music for them every day.
In return, the fleas made a bigger ukulele for her: it has n strings, and each string has (10^{18} + 1) frets n... |
### Prompt
Develop a solution in cpp to the problem described below:
You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest.
The forest
The Biridian Forest is a two-dimensional grid consisting of r rows and c colu... |
### Prompt
Please formulate a Cpp solution to the following problem:
Let J(n) be a three-dimensional body that
* is a union of unit cubes whose all vertices lie on integer coordinates,
* contains all points that are closer than the distance of βn to the origin, and
* is the smallest of all such bodies.
The figure... |
### Prompt
Please provide a cpp coded solution to the problem described below:
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.
At least how many operations are necessary to satisfy the following ... |
### Prompt
Generate a cpp solution to the following problem:
The country has n cities and n - 1 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to n inclusive.
All the roads are initially bad, but the governmen... |
### Prompt
Construct a CPP code solution to the problem outlined:
Awruk is taking part in elections in his school. It is the final round. He has only one opponent β Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a... |
### Prompt
Please create a solution in CPP to the following problem:
Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are n junctions and m two way roads, at which one can get from each junction to any other one. The mayor wants to close some road... |
### Prompt
Please formulate a CPP solution to the following problem:
A programming coach has n students to teach. We know that n is divisible by 3. Let's assume that all students are numbered from 1 to n, inclusive.
Before the university programming championship the coach wants to split all students into groups of t... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:
* If the number of cookies in his hand is odd, eat one of those cookies; if the number is e... |
### Prompt
Your task is to create a cpp solution to the following problem:
Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possible. Russell was trying ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Your company was appointed to lay new asphalt on the highway of length n. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.
Skipping the repair is neces... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Snuke loves working out. He is now exercising N times.
Before he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.
Find Snuke's power after he exercises N times. Since the answer can be ... |
### Prompt
Generate a Cpp solution to the following problem:
problem
The IOI country consists of N towns from town 1 to town N, and the towns are connected by roads. The IOI country has K roads, all of which connect two different towns. Cars can move freely in both directions on the road, but they cannot go from one... |
### Prompt
Please formulate a Cpp solution to the following problem:
Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are?
Constraints
* 1 β€ A β€ B < 2^{60}
* A and B are integers.
I... |
### Prompt
Please formulate a Cpp solution to the following problem:
One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to chec... |
### Prompt
Please create a solution in Cpp to the following problem:
problem
Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.
The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character... |
### Prompt
Develop a solution in Cpp to the problem described below:
Vasya bought the collected works of a well-known Berland poet Petya in n volumes. The volumes are numbered from 1 to n. He thinks that it does not do to arrange the book simply according to their order. Vasya wants to minimize the number of the disp... |
### Prompt
Please create a solution in CPP to the following problem:
There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 ti... |
### Prompt
Develop a solution in Cpp to the problem described below:
You are given a forest β an undirected graph with n vertices such that each its connected component is a tree.
The diameter (aka "longest shortest path") of a connected undirected graph is the maximum number of edges in the shortest path between an... |
### Prompt
Please formulate a CPP solution to the following problem:
A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count.
The game goes as follows. Kids stand in circle. Let's agree to think of the children as ... |
### Prompt
Generate a CPP solution to the following problem:
Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight.
Judgment | Sight
--- | ---
... |
### Prompt
Generate a cpp solution to the following problem:
There are N cubes stacked vertically on a desk.
You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is `0`, and blue if that character is `1`.
You can perform the following operation any numbe... |
### Prompt
Develop a solution in CPP to the problem described below:
DZY has a sequence a, consisting of n integers.
We'll call a sequence ai, ai + 1, ..., aj (1 β€ i β€ j β€ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a,... |
### Prompt
Your task is to create a CPP solution to the following problem:
Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understanding... |
### Prompt
Your task is to create a CPP solution to the following problem:
The fact that any positive integer has a representation as the sum of at most four positive squares (i.e. squares of positive integers) is known as Lagrangeβs Four-Square Theorem. The first published proof of the theorem was given by Joseph-Lo... |
### Prompt
Create a solution in Cpp for the following problem:
It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.
In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and ... |
### Prompt
In CPP, your task is to solve the following problem:
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 is more than two). Let us remind you... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Medicine faculty of Berland State University has just finished their admission campaign. As usual, about 80\% of applicants are girls and majority of them are going to live in the university dormitory for the next 4 (hopefully) years.
The... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya wonders eager... |
### Prompt
Construct a CPP code solution to the problem outlined:
Arkady's code contains n variables. Each variable has a unique name consisting of lowercase English letters only. One day Arkady decided to shorten his code.
He wants to replace each variable name with its non-empty prefix so that these new names are ... |
### Prompt
Your task is to create a CPP solution to the following problem:
Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some v... |
### Prompt
Generate a cpp solution to the following problem:
problem
A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction.
The w roads in the north-south direction are numbered 1, 2, .... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
A programming competition site AtCode regularly holds programming contests.
The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.
The contest after the ABC is called ARC, which is rated for... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You're given an array a of length 2n. Is it possible to reorder it in such way so that the sum of the first n elements isn't equal to the sum of the last n elements?
Input
The first line contains an integer n (1 β€ n β€ 1000), where 2n is the number of... |
### Prompt
Develop a solution in Cpp to the problem described below:
Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them.
For that a ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:
Find k integers such that the sum of two to the power of each number equals to... |
### Prompt
Generate a CPP solution to the following problem:
The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.
Given a sequence of n integers p1, p2,... |
### Prompt
Please provide a CPP coded solution to the problem described below:
There is a grid with H rows and W columns, where each square is painted black or white.
You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted ... |
### Prompt
Please create a solution in Cpp to the following problem:
Kenkoooo found a simple connected graph. The vertices are numbered 1 through n. The i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.
Kenkoooo is trying to write a positive integer in each vertex so that the following condition is... |
### Prompt
Create a solution in CPP for the following problem:
D: Sontaku (Surmise)
Some twins like even numbers.
Count how many even numbers are in $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $.
input
The integer $ N $ is given on the first line.
On the second line, $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.
A snake is a pattern on a n by m table. Denote c-th cell of r-th row as ... |
### Prompt
Create a solution in Cpp for the following problem:
You must have heard of the two brothers dreaming of ruling the world. With all their previous plans failed, this time they decided to cooperate with each other in order to rule the world.
As you know there are n countries in the world. These countries a... |
### Prompt
Develop a solution in cpp to the problem described below:
problem
Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to find t... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more.
Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered... |
### Prompt
Construct a CPP code solution to the problem outlined:
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his friends by n... |
### Prompt
Construct a cpp code solution to the problem outlined:
You are given an array a of n integers. Define the cost of some array t as follows:
$$$cost(t) = β_{x β set(t) } last(x) - first(x),$$$
where set(t) is the set of all values in t without repetitions, first(x), and last(x) are the indices of the firs... |
### Prompt
Develop a solution in Cpp to the problem described below:
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.
Here... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given two circles. Find the area of their intersection.
Input
The first line contains three integers x1, y1, r1 ( - 109 β€ x1, y1 β€ 109, 1 β€ r1 β€ 109) β the position of the center and the radius of the first circle.
The second li... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Shubham has a binary string s. A binary string is a string containing only characters "0" and "1".
He can perform the following operation on the string any amount of times:
* Select an index of the string, and flip the character at th... |
### Prompt
Develop a solution in Cpp to the problem described below:
There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 ti... |
### Prompt
Please provide a cpp coded solution to the problem described below:
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 vertices must have... |
### Prompt
Your task is to create a CPP solution to the following problem:
The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equiv... |
### Prompt
Generate a Cpp solution to the following problem:
There is an infinite sequence consisting of all positive integers in the increasing order: p = {1, 2, 3, ...}. We performed n swap operations with this sequence. A swap(a, b) is an operation of swapping the elements of the sequence on positions a and b. You... |
### Prompt
Please formulate a cpp solution to the following problem:
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a non... |
### Prompt
Your task is to create a CPP solution to the following problem:
The map of the capital of Berland can be viewed on the infinite coordinate plane. Each point with integer coordinates contains a building, and there are streets connecting every building to four neighbouring buildings. All streets are parallel... |
### Prompt
Create a solution in CPP for the following problem:
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 β€ |V| β€ 100
* 0 β€ |E| β€ 1,000
* 0 β€ wi β€ 10,000
* G has arborescence(s) with the root r
Input
|V| |E... |
### Prompt
Develop a solution in cpp to the problem described below:
There is a grid of size W Γ H surrounded by walls. Some cells in the grid are occupied by slimes. The slimes want to unite with each other and become a "King Slime".
In each move, a slime can move to east, west, south and north direction until it e... |
### Prompt
Generate a Cpp solution to the following problem:
You are given a permutation of n numbers p1, p2, ..., pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l β€ r) and reverse the order of the elements pl, pl + 1, ..., pr. Your task is to find the expected valu... |
### Prompt
Create a solution in cpp for the following problem:
Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 β the total number of bombs in... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more poss... |
### Prompt
Please create a solution in cpp to the following problem:
Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.
To improve his division skills, Oleg came up with t pairs of integers p_i and q_i and for each pair decided to find the greatest integer x_i, such th... |
### Prompt
Please create a solution in cpp to the following problem:
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... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is n.
There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains 2 apartments, every other ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very diffic... |
### Prompt
In CPP, your task is to solve the following problem:
Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows:
* When a device in state A receives a ball from ei... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
According to the legends the king of Berland Berl I was noted for his love of beauty and order. One day he ordered to tile the palace hall's floor where balls and receptions used to take place with black and white tiles according to a regu... |
### Prompt
Your task is to create a cpp solution to the following problem:
Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.
He will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i β j) are... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
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 the maximal number of s... |
### Prompt
Develop a solution in CPP to the problem described below:
Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types:
1. 1 l r x β increase all integers on the segment from l to r by values x;
2. 2 l r β find <image>, where f(x) is the x-th Fibo... |
### Prompt
Please provide a cpp coded solution to the problem described below:
You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.
* Assume that, for each integer i between 1 and N (inclusive),... |
### Prompt
Your task is to create a Cpp solution to the following problem:
One day Petya got a set of wooden cubes as a present from his mom. Petya immediately built a whole city from these cubes.
The base of the city is an n Γ n square, divided into unit squares. The square's sides are parallel to the coordinate ax... |
### Prompt
Your task is to create a CPP solution to the following problem:
Generalized leap year
Normally, whether or not the year x is a leap year is defined as follows.
1. If x is a multiple of 400, it is a leap year.
2. Otherwise, if x is a multiple of 100, it is not a leap year.
3. Otherwise, if x is a multiple... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison.
Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomacha... |
### Prompt
Generate a Cpp solution to the following problem:
I decided to play rock-paper-scissors with a group of five good friends. Rock-paper-scissors has three hands: goo, choki, and par. If the game between goo and choki is a match between goo and choki, goo is "winning" and choki is "losing". , Par and Goo have... |
### Prompt
Your task is to create a Cpp solution to the following problem:
This is an interactive problem. In the output section below you will see the information about flushing the output.
On Sunday Leha the hacker took Nura from the house where she lives and went with her to one of the most luxurious restaurants ... |
### Prompt
Generate a CPP solution to the following problem:
Levko loves strings of length n, consisting of lowercase English letters, very much. He has one such string s. For each string t of length n, Levko defines its beauty relative to s as the number of pairs of indexes i, j (1 β€ i β€ j β€ n), such that substring ... |
### Prompt
Please create a solution in CPP to the following problem:
Indiana Jones found ancient Aztec catacombs containing a golden idol. The catacombs consists of n caves. Each pair of caves is connected with a two-way corridor that can be opened or closed. The entrance to the catacombs is in the cave 1, the idol a... |
### Prompt
In Cpp, your task is to solve the following problem:
We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result.
Constraints
... |
### Prompt
Please create a solution in cpp to the following problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays on... |
### Prompt
Construct a CPP code solution to the problem outlined:
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!
You are given n nonnegative integers a_1, a_2, ..., a_n arranged in a circle, where n must be odd (ie. n-1 is divisible by 2). Fo... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all di... |
### Prompt
Your task is to create a Cpp solution to the following problem:
The goal of the 15 puzzle problem is to complete pieces on $4 \times 4$ cells where one of the cells is empty space.
In this problem, the space is represented by 0 and pieces are represented by integers from 1 to 15 as shown below.
1 2 3 4
... |
### Prompt
Your task is to create a Cpp solution to the following problem:
We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied:
* For each i (1 β€ i β€ N), there are exactly a_i squares painted in Color i. Here,... |
### Prompt
In CPP, your task is to solve the following problem:
Arkady coordinates rounds on some not really famous competitive programming platform. Each round features n problems of distinct difficulty, the difficulties are numbered from 1 to n.
To hold a round Arkady needs n new (not used previously) problems, on... |
### Prompt
In CPP, your task is to solve the following problem:
You have a set of n discs, the i-th disc has radius i. Initially, these discs are split among m towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order of their radii from bottom to top.
You would like t... |
### Prompt
Create a solution in cpp for the following problem:
The New Year holidays are over, but Resha doesn't want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree.
The New Year tree is an undirected tree with n vertices and root in the verte... |
### Prompt
Construct a cpp code solution to the problem outlined:
The competitors of Bubble Cup X gathered after the competition and discussed what is the best way to get to know the host country and its cities.
After exploring the map of Serbia for a while, the competitors came up with the following facts: the coun... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Mike is trying rock climbing but he is awful at it.
There are n holds on the wall, i-th hold is at height ai off the ground. Besides, let the sequence ai increase, that is, ai < ai + 1 for all i from 1 to n - 1; we will call such sequenc... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given a string s consisting of exactly n characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.
Your task is to replace minimum number of characters in this string with other characters to obtain ... |
### Prompt
Your task is to create a CPP solution to the following problem:
Smart Beaver became interested in drawing. He draws suns. However, at some point, Smart Beaver realized that simply drawing suns is boring. So he decided to design a program that will process his drawings. You are given a picture drawn by the ... |
### Prompt
Please create a solution in cpp to the following problem:
Alice has a lovely piece of cloth. It has the shape of a square with a side of length a centimeters. Bob also wants such piece of cloth. He would prefer a square with a side of length b centimeters (where b < a). Alice wanted to make Bob happy, so s... |
### Prompt
Your task is to create a CPP solution to the following problem:
Let S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555.
Given a number X, compute <image> modulo 109 + 7.
Input
The first line of input will contain t... |
### Prompt
Please formulate a Cpp solution to the following problem:
Petya is preparing for his birthday. He decided that there would be n different dishes on the dinner table, numbered from 1 to n. Since Petya doesn't like to cook, he wants to order these dishes in restaurants.
Unfortunately, all dishes are prepare... |
### Prompt
Please formulate a CPP solution to the following problem:
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a... |
### Prompt
Develop a solution in CPP to the problem described below:
Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water.
The vertices of the tree are numbered from 1 to n with the root at vertex 1. For each vertex,... |
### Prompt
Develop a solution in Cpp to the problem described below:
We will call a non-negative integer increasing if, for any two adjacent digits in its decimal representation, the digit to the right is greater than or equal to the digit to the left. For example, 1558, 11, 3 and 0 are all increasing; 10 and 2017031... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.