text
stringlengths
424
69.5k
### Prompt Please formulate a CPP solution to the following problem: There is a strange peculiarity: if you connect the cities of Rostov, Taganrog and Shakhty, peculiarly, you get a triangle «Unbelievable But True» Students from many different parts of Russia and abroad come to Summer Informatics School. You marked...
### Prompt Develop a solution in CPP to the problem described below: Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is a filler word ogo in Oleg's speech. All wo...
### Prompt Please formulate a CPP solution to the following problem: Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There ar...
### Prompt Construct a Cpp code solution to the problem outlined: This is a harder version of the problem. In this version, n ≤ 50 000. There are n distinct points in three-dimensional space numbered from 1 to n. The i-th point has coordinates (x_i, y_i, z_i). The number of points n is even. You'd like to remove al...
### Prompt Please formulate a cpp solution to the following problem: There are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points? Here, the Manhattan distance betwe...
### Prompt Please create a solution in cpp to the following problem: Over time, Alexey's mail box got littered with too many letters. Some of them are read, while others are unread. Alexey's mail program can either show a list of all letters or show the content of a single letter. As soon as the program shows the co...
### Prompt Your challenge is to write a Cpp solution to the following problem: Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, wa...
### Prompt Please provide a CPP coded solution to the problem described below: Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not...
### Prompt Please create a solution in cpp to the following problem: Takahashi will play a game using a piece on an array of squares numbered 1, 2, \cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \cdots, N: P_1, P_2, \cdots, P_N. Now, he will choose one square and place...
### Prompt Please create a solution in CPP to the following problem: Just to remind, girls in Arpa's land are really nice. Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendship gr...
### Prompt Please create a solution in CPP to the following problem: Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics. Polyc...
### Prompt In CPP, your task is to solve the following problem: We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of length n, with non-negative elements strictly less then 2l meet the following condition: <image>? Here operation <image> means bitwise AND (in ...
### Prompt Please formulate a cpp solution to the following problem: Dasha decided to have a rest after solving the problem D and began to look photos from previous competitions. Let's call photos as the matrix with the size n × m, which consists of lowercase English letters. Some k photos especially interested her...
### Prompt Construct a CPP code solution to the problem outlined: There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the le...
### Prompt Generate a CPP solution to the following problem: Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated. There are n video car...
### Prompt Create a solution in CPP for the following problem: Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). In this contest, a contestant will fi...
### Prompt Please formulate a cpp solution to the following problem: In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles. Tania has managed to collect n different...
### Prompt Please create a solution in CPP to the following problem: Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds. There are two perfect binary trees of height H, each with the standard numeration of vertices from 1 to 2^H-1. The root is 1 and the children of x ...
### Prompt Construct a CPP code solution to the problem outlined: Find the minimum prime number greater than or equal to X. Constraints * 2 \le X \le 10^5 * All values in input are integers. Input Input is given from Standard Input in the following format: X Output Print the minimum prime number greater than...
### Prompt Generate a Cpp solution to the following problem: There is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 → 6 → 7 → 8 → 9 → 5 as shown in the figure. <image> For this bus...
### Prompt Please create a solution in CPP to the following problem: A mischievous notice has arrived from the primitive slow-life organization "Akaruda". Akaruda is famous for mischief such as throwing a pie at the face of a VIP, but recently it has become more radical, such as using gunpowder to sprinkle rat firewo...
### Prompt Your task is to create a CPP solution to the following problem: You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons ca...
### Prompt Generate a CPP solution to the following problem: A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring. You are given a set of strings. A string (not necessarily from this set) is called good if all elements ...
### Prompt Your challenge is to write a Cpp solution to the following problem: HQ9+ is a joke programming language which has only four one-character instructions: * "H" prints "Hello, World!", * "Q" prints the source code of the program itself, * "9" prints the lyrics of "99 Bottles of Beer" song, * "+" inc...
### Prompt Create a solution in CPP for the following problem: Elections in Berland are coming. There are only two candidates — Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by their influenc...
### Prompt Develop a solution in CPP to the problem described below: Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead. As you may know, the coolest photos are on the fi...
### Prompt Develop a solution in Cpp to the problem described below: You are given an array a_1, a_2, …, a_n. You need to perform q queries of the following two types: 1. "MULTIPLY l r x" — for every i (l ≤ i ≤ r) multiply a_i by x. 2. "TOTIENT l r" — print \varphi(∏ _{i=l}^{r} a_i) taken modulo 10^9+7, where \...
### Prompt Please create a solution in cpp to the following problem: Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not. You are given a segment [L; R]. Count the ...
### Prompt Please formulate a CPP solution to the following problem: A telephone number is a sequence of exactly 11 digits such that its first digit is 8. Vasya and Petya are playing a game. Initially they have a string s of length n (n is odd) consisting of digits. Vasya makes the first move, then players alternate...
### Prompt Your challenge is to write a cpp solution to the following problem: Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well. There are n cities in Berland. People can travel between cities using two-directio...
### Prompt Please create a solution in CPP to the following problem: In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the f...
### Prompt Please formulate a CPP solution to the following problem: Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to scroll d...
### Prompt Your task is to create a cpp solution to the following problem: N friends of Takahashi has come to a theme park. To ride the most popular roller coaster in the park, you must be at least K centimeters tall. The i-th friend is h_i centimeters tall. How many of the Takahashi's friends can ride the roller ...
### Prompt Please provide a Cpp coded solution to the problem described below: You are given an array a of n integers. You want to make all elements of a equal to zero by doing the following operation exactly three times: * Select a segment, for each number in this segment we can add a multiple of len to it, wher...
### Prompt Please provide a CPP coded solution to the problem described below: Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expre...
### Prompt Construct a cpp code solution to the problem outlined: Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go. Dr. Evil is interested in sets, He has a set of n integers. Dr. Evil cal...
### Prompt Generate a CPP solution to the following problem: Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string s, consisting of characters "x" and "y", and uses two following operations at runtime: 1. Find two consecutive characters i...
### Prompt In cpp, your task is to solve the following problem: You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk. Output the sum of costs over all non-empty subsets of people. Input Only line of input contains two integ...
### Prompt Generate a Cpp solution to the following problem: The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, the j-th (1 ≤ j ≤ n) element of the permutation b — as bj. The distance betwee...
### Prompt Develop a solution in cpp to the problem described below: The only difference between easy and hard versions is the constraints. Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kittens, of course). Vova likes all ...
### Prompt Your task is to create a Cpp solution to the following problem: Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the to...
### Prompt Please provide a Cpp coded solution to the problem described below: Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length k is vowelly if there are positive integers n and m such that n⋅ m = k and when the word is written by using n rows a...
### Prompt Create a solution in cpp for the following problem: Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception. His song consists of n notes, which ...
### Prompt Create a solution in cpp for the following problem: Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to which one...
### Prompt Construct a CPP code solution to the problem outlined: A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an im...
### Prompt Your task is to create a Cpp solution to the following problem: There are n students numerated from 1 to n. The level of the i-th student is a_i. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements diffe...
### Prompt Construct a Cpp code solution to the problem outlined: Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible. String s consists only of lowercase Latin letters, and it is allowed to change characters ...
### Prompt Please formulate a Cpp solution to the following problem: Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operatio...
### Prompt Develop a solution in cpp to the problem described below: Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2...
### Prompt Please create a solution in cpp to the following problem: Drazil is playing a math game with Varda. Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>. First, they choose a decimal number a consisting of n digits that contains at least one digit lar...
### Prompt Please formulate a Cpp solution to the following problem: Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team. At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and t. You need to transform word s into w...
### Prompt Your task is to create a CPP solution to the following problem: Dreamoon likes strings. Today he created a game about strings: String s_1, s_2, …, s_n is beautiful if and only if for each 1 ≤ i < n, s_i ≠ s_{i+1}. Initially, Dreamoon has a string a. In each step Dreamoon can choose a beautiful substring ...
### Prompt Your task is to create a CPP solution to the following problem: The only difference between easy and hard versions is constraints. There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his boo...
### Prompt Please provide a CPP coded solution to the problem described below: There are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i ...
### Prompt Construct a CPP code solution to the problem outlined: You are storing an integer array of length m in a database. To maintain internal integrity and protect data, the database stores n copies of this array. Unfortunately, the recent incident may have altered the stored information in every copy in the da...
### Prompt Create a solution in cpp for the following problem: The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are not connected ...
### Prompt In Cpp, your task is to solve the following problem: Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations: * add(s, t, x): add x to as, as+1, ..., at. * getSum(s, t): report the sum of as, as+1, ..., at. Note that the initial values of ai (i = 1, 2, . . . ...
### Prompt Generate a cpp solution to the following problem: Digital collectible card games have become very popular recently. So Vova decided to try one of these. Vova has n cards in his collection. Each of these cards is characterised by its power pi, magic number ci and level li. Vova wants to build a deck with t...
### Prompt Please formulate a cpp solution to the following problem: Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berla...
### Prompt Develop a solution in cpp to the problem described below: There are n robbers at coordinates (a_1, b_1), (a_2, b_2), ..., (a_n, b_n) and m searchlight at coordinates (c_1, d_1), (c_2, d_2), ..., (c_m, d_m). In one move you can move each robber to the right (increase a_i of each robber by one) or move eac...
### Prompt Develop a solution in Cpp to the problem described below: In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong — the oldest among the inhabitants of Mainframe. But still he managed to get some information from there. For example, he ma...
### Prompt Please provide a CPP coded solution to the problem described below: A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show. The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the ho...
### Prompt In cpp, your task is to solve the following problem: Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to go out from each flat. Also, each flat is connected with t...
### Prompt Please formulate a cpp solution to the following problem: Everybody knows that lucky numbers are positive integers that contain only lucky digits 4 and 7 in their decimal representation. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Polo the Penguin have two positive integers l and r (...
### Prompt Your task is to create a Cpp solution to the following problem: This time our child has a simple polygon. He has to find the number of ways to split the polygon into non-degenerate triangles, each way must satisfy the following requirements: * each vertex of each triangle is one of the polygon vertex; ...
### Prompt Create a solution in cpp for the following problem: There were n groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team. The coach decided to form teams of exactly thre...
### Prompt Your challenge is to write a Cpp solution to the following problem: A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show. The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the ho...
### Prompt Please create a solution in CPP to the following problem: Problem Statement There is a maze which can be described as a W \times H grid. The upper-left cell is denoted as (1, 1), and the lower-right cell is (W, H). You are now at the cell (1, 1) and have to go to the cell (W, H). However, you can only mov...
### Prompt Please create a solution in CPP to the following problem: Under the command "Save Sergeant Ryan," Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio. So...
### Prompt Generate a cpp solution to the following problem: Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. ...
### Prompt Please formulate a Cpp solution to the following problem: You are given an array a of length n that consists of zeros and ones. You can perform the following operation multiple times. The operation consists of two steps: 1. Choose three integers 1 ≤ x < y < z ≤ n, that form an arithmetic progression (...
### Prompt Develop a solution in cpp to the problem described below: [Æsir - CHAOS](https://soundcloud.com/kivawu/aesir-chaos) [Æsir - V.](https://soundcloud.com/kivawu/aesir-v) "Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect. The time right now...... 00:01:12........
### Prompt Develop a solution in CPP to the problem described below: Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other. In this metropolit...
### Prompt Your challenge is to write a CPP solution to the following problem: Tsuruga Castle, a symbol of Aizuwakamatsu City, was named "Tsuruga Castle" after Gamo Ujisato built a full-scale castle tower. You can overlook the Aizu basin from the castle tower. On a clear day, you can see Tsuruga Castle from the summi...
### Prompt Construct a cpp code solution to the problem outlined: AquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. Aq...
### Prompt Please create a solution in cpp to the following problem: Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming ta...
### Prompt In CPP, your task is to solve the following problem: — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere ...
### Prompt Create a solution in cpp for the following problem: On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads b...
### Prompt Please formulate a Cpp solution to the following problem: You are given an integer sequence a_1, a_2, ..., a_n. Find the number of pairs of indices (l, r) (1 ≤ l ≤ r ≤ n) such that the value of median of a_l, a_{l+1}, ..., a_r is exactly the given number m. The median of a sequence is the value of an ele...
### Prompt Construct a cpp code solution to the problem outlined: Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00...
### Prompt Construct a Cpp code solution to the problem outlined: A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. <image> You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and ...
### Prompt Your task is to create a CPP solution to the following problem: Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two groups. If the division...
### Prompt Please formulate a cpp solution to the following problem: JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a_1, a_2, ..., a_n of integers, such that 1 ≤ a_1 < a_2 < … < a_n ≤ 10^3, and then went to the bathroom. JATC decided to prank...
### Prompt Develop a solution in Cpp to the problem described below: You are given an array s of n non-negative integers. A 5-tuple of integers (a, b, c, d, e) is said to be valid if it satisfies the following conditions: * 1 ≤ a, b, c, d, e ≤ n * (sa | sb) & sc & (sd ^ se) = 2i for some integer i * sa & sb ...
### Prompt Please provide a CPP coded solution to the problem described below: Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive intege...
### Prompt Your task is to create a cpp solution to the following problem: Recently, Olya received a magical square with the size of 2^n× 2^n. It seems to her sister that one square is boring. Therefore, she asked Olya to perform exactly k splitting operations. A Splitting operation is an operation during which Oly...
### Prompt Your challenge is to write a CPP solution to the following problem: During the loading of the game "Dungeons and Candies" you are required to get descriptions of k levels from the server. Each description is a map of an n × m checkered rectangular field. Some cells of the field contain candies (each cell h...
### Prompt Your task is to create a cpp solution to the following problem: You are in charge of controlling a dam. The dam can store at most L liters of water. Initially, the dam is empty. Some amount of water flows into the dam every morning, and any amount of water may be discharged every night, but this amount nee...
### Prompt Please create a solution in cpp to the following problem: Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + ...
### Prompt Create a solution in Cpp for the following problem: You are given an undirected graph G. G has N vertices and M edges. The vertices are numbered from 1 through N, and the i-th edge (1 ≤ i ≤ M) connects Vertex a_i and b_i. G does not have self-loops and multiple edges. You can repeatedly perform the operat...
### Prompt Your challenge is to write a cpp solution to the following problem: You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n. You need to permute the array elements so that value <image> became minimal possible. In particular, it is allowed not to...
### Prompt Please provide a cpp coded solution to the problem described below: Egor wants to achieve a rating of 1600 points on the well-known chess portal ChessForces and he needs your help! Before you start solving the problem, Egor wants to remind you how the chess pieces move. Chess rook moves along straight lin...
### Prompt Generate a CPP solution to the following problem: Your friend gave you a dequeue D as a birthday present. D is a horizontal cylinder that contains a row of N jewels. The values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values. In the beginning, you have n...
### Prompt Generate a Cpp solution to the following problem: Valera is a collector. Once he wanted to expand his collection with exactly one antique item. Valera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction price of the j-th object of the i-th seller is sij. Valera gets on ...
### Prompt Your challenge is to write a cpp solution to the following problem: On the way to school, Karen became fixated on the puzzle game on her phone! <image> The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists o...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m. Input The first line contains two num...
### Prompt Develop a solution in Cpp to the problem described below: Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same ...
### Prompt In CPP, your task is to solve the following problem: Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemica...
### Prompt Generate a CPP solution to the following problem: What-The-Fatherland is a strange country! All phone numbers there are strings consisting of lowercase English letters. What is double strange that a phone number can be associated with several bears! In that country there is a rock band called CF consistin...
### Prompt Please provide a cpp coded solution to the problem described below: Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum ...