text stringlengths 424 69.5k |
|---|
### Prompt
Generate a Cpp solution to the following problem:
Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).
Constraints
* 1 \leq N \leq 10^5
Input
Input is given from Standard Input in the following format:... |
### Prompt
In cpp, your task is to solve the following problem:
Instructors of Some Informatics School make students go to bed.
The house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their assigned rooms. Th... |
### Prompt
Please create a solution in Cpp to the following problem:
Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m columns. For example, in a 3 ... |
### Prompt
Develop a solution in Cpp to the problem described below:
Arkady bought an air ticket from a city A to a city C. Unfortunately, there are no direct flights, but there are a lot of flights from A to a city B, and from B to C.
There are n flights from A to B, they depart at time moments a_1, a_2, a_3, ..., ... |
### Prompt
In cpp, your task is to solve the following problem:
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string cons... |
### Prompt
Please create a solution in CPP to the following problem:
Let's consider one interesting word game. In this game you should transform one word into another through special operations.
Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is tr... |
### Prompt
Develop a solution in Cpp to the problem described below:
Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet c... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Imagine an n × m grid with some blocked cells. The top left cell in the grid has coordinates (1, 1) and the bottom right cell has coordinates (n, m). There are k blocked cells in the grid and others are empty. You flash a laser beam from t... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Jzzhu has two integers, n and m. He calls an integer point (x, y) of a plane special if 0 ≤ x ≤ n and 0 ≤ y ≤ m. Jzzhu defines a unit square as a square with corners at points (x, y), (x + 1, y), (x + 1, y + 1), (x, y + 1), where x and y are s... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
G: Working
Kou decided to do the same number of jobs every day for the next $ N $.
$ A_i $ jobs are added on the $ i $ day of the $ N $ day.
Mr. Kou has no work to do now, and he doesn't have to finish all the work by the $ N $ day.
Ho... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Snuke loves constructing integer sequences.
There are N piles of stones, numbered 1 through N. The pile numbered i consists of a_i stones.
Snuke will construct an integer sequence s of length Σa_i, as follows:
1. Among the piles with the la... |
### Prompt
In cpp, your task is to solve the following problem:
Nauuo is a girl who loves traveling.
One day she went to a tree, Old Driver Tree, literally, a tree with an old driver on it.
The tree is a connected graph consisting of n nodes and n-1 edges. Each node has a color, and Nauuo will visit the ODT through... |
### Prompt
Your task is to create a CPP solution to the following problem:
In this task you have to write a program dealing with nonograms on fields no larger than 5 × 20.
Simplified nonogram is a task where you have to build such field (each cell is either white or black) that satisfies the given information about ... |
### Prompt
Please create a solution in CPP to the following problem:
Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or cons... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Ataru Oafoot of Aizu Gakuen University High School decided to play with a slot machine.
When you insert a medal on this machine, three reels will start spinning and each reel will stop automatically. In a normal game (normal game), 3 meda... |
### Prompt
Please formulate a CPP solution to the following problem:
You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematician. She/he can have no specialization, but can't have... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given an array a_1, a_2, ..., a_n where all a_i are integers and greater than 0.
In one operation, you can choose two different indices i and j (1 ≤ i, j ≤ n). If gcd(a_i, a_j) is equal to the minimum element of the whole array a, you can s... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points.
Input
The first line of input contains one integer number N (1 ≤ N ≤ 100 000) — the number of points. Each of the follo... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given n numbers a_1, a_2, ..., a_n. With a cost of one coin you can perform the following operation:
Choose one of these numbers and add or subtract 1 from it.
In particular, we can apply this operation to the same number several... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will as... |
### Prompt
Your task is to create a CPP solution to the following problem:
Kefa decided to celebrate his first big salary by going to the restaurant.
He lives by an unusual park. The park is a rooted tree consisting of n vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our h... |
### Prompt
Please create a solution in CPP to the following problem:
You are given two integers a and b. Determine if a+b=15 or a\times b=15 or neither holds.
Note that a+b=15 and a\times b=15 do not hold at the same time.
Constraints
* 1 \leq a,b \leq 15
* All values in input are integers.
Input
Input is given ... |
### Prompt
Develop a solution in Cpp to the problem described below:
Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game under th... |
### Prompt
In cpp, your task is to solve the following problem:
There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.
Takahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at m... |
### Prompt
In Cpp, your task is to solve the following problem:
Initially, you have the array a consisting of one element 1 (a = [1]).
In one move, you can do one of the following things:
* Increase some (single) element of a by 1 (choose some i from 1 to the current length of a and increase a_i by one);
* App... |
### Prompt
Please create a solution in cpp 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
Construct a CPP code solution to the problem outlined:
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.
* insert($key$, $x$): Insert an element formed by a pair of $key... |
### Prompt
Generate a Cpp solution to the following problem:
To AmShZ, all arrays are equal, but some arrays are more-equal than others. Specifically, the arrays consisting of n elements from 1 to n that can be turned into permutations of numbers from 1 to n by adding a non-negative integer to each element.
Mashtali... |
### Prompt
Generate a CPP solution to the following problem:
The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every ... |
### Prompt
Please create a solution in cpp to the following problem:
You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do noth... |
### Prompt
Please formulate a CPP solution to the following problem:
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining card... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We co... |
### Prompt
Create a solution in Cpp for the following problem:
An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, $ ... |
### Prompt
Please create a solution in Cpp to the following problem:
A permutation p is an ordered group of numbers p1, p2, ..., pn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1, p2, ..., pn.
Simon has a positive integer n and a non-negativ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
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... |
### Prompt
Construct a CPP code solution to the problem outlined:
Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.
Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his... |
### Prompt
Please formulate a cpp solution to the following problem:
'In Boolean logic, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of clauses, where a clause is a disjunction of literals' (cited from https://en.wikipedia.org/wiki/Conjunctive_normal_form)
In the other ... |
### Prompt
In cpp, your task is to solve the following problem:
Given simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.
The boundary of n-gon belongs to polygon. It is possible that n-gon contains... |
### Prompt
In CPP, your task is to solve the following problem:
problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in e... |
### Prompt
Develop a solution in Cpp to the problem described below:
This is an interactive problem.
Vasya and Petya are going to play the following game: Petya has some positive integer number a. After that Vasya should guess this number using the following questions. He can say a pair of non-negative integer numbe... |
### Prompt
Please formulate a cpp solution to the following problem:
Two-gram is an ordered pair (i.e. string of length two) of capital Latin letters. For example, "AZ", "AA", "ZA" — three distinct two-grams.
You are given a string s consisting of n capital Latin letters. Your task is to find any two-gram contained ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:
1. All cells in a set have the same color.
2. Every two cells in a set share row or column.
Input
T... |
### Prompt
Please create a solution in cpp to the following problem:
One of the games that uses the Hyakunin Isshu tag is "Buddhist turning". It is a simple game that uses only picture cards, so it is widely enjoyed. There are various derivative types of rules, but the shaved turn considered here is performed by N pa... |
### Prompt
Please formulate a cpp solution to the following problem:
In the country there are exactly n cities numbered with positive integers from 1 to n. In each city there is an airport is located.
Also, there is the only one airline, which makes m flights. Unfortunately, to use them, you need to be a regular cus... |
### Prompt
In CPP, your task is to solve the following problem:
Two best friends Serozha and Gena play a game.
Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of a1 > a2 > ... > ak > 0 stones. The piles... |
### Prompt
Create a solution in cpp for the following problem:
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Given are three integers N, K, and S.
Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exist... |
### Prompt
Develop a solution in CPP to the problem described below:
Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any leading zeroes and it'll be ... |
### Prompt
Please create a solution in Cpp to the following problem:
There are n chips arranged in a circle, numbered from 1 to n.
Initially each chip has black or white color. Then k iterations occur. During each iteration the chips change their colors according to the following rules. For each chip i, three chips... |
### Prompt
Develop a solution in cpp to the problem described below:
Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.
You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 disti... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to ti... |
### Prompt
Create a solution in cpp for the following problem:
Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the vertices on the p... |
### Prompt
Please create a solution in cpp to the following problem:
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:
* $update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.
* $getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$.
Note that the ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then i... |
### Prompt
Your task is to create a cpp solution to the following problem:
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two h... |
### Prompt
Your task is to create a CPP solution to the following problem:
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations:
* put the given number into the heap;
* get the value of the minimum element in the heap;
* extract th... |
### Prompt
Develop a solution in CPP to the problem described below:
One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get... |
### Prompt
In cpp, your task is to solve the following problem:
Harry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Secrets. Harry wants to know the di... |
### Prompt
In CPP, your task is to solve the following problem:
Given is a positive integer L. Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.
Constraints
* 1 ≤ L ≤ 1000
* L is an integer.
Input
Input is given from Standard Input in the followi... |
### Prompt
Develop a solution in cpp to the problem described below:
Railroad Trip
There are N cities in the JOI country, numbered 1, 2, ..., and N, respectively. In addition, there are N − 1 railroads, which are numbered 1, 2, ..., and N − 1, respectively. The railroad i (1 ≤ i ≤ N − 1) connects the city i and the ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine.
For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine an... |
### Prompt
Create a solution in CPP for the following problem:
Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb being ... |
### Prompt
Construct a CPP code solution to the problem outlined:
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.
His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no ch... |
### Prompt
In cpp, your task is to solve the following problem:
Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc.
We'll say that string s can be obtained from string t, if we can remove some... |
### Prompt
In CPP, your task is to solve the following problem:
Omkar is playing his favorite pixelated video game, Bed Wars! In Bed Wars, there are n players arranged in a circle, so that for all j such that 2 ≤ j ≤ n, player j - 1 is to the left of the player j, and player j is to the right of player j - 1. Additio... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system.
The le... |
### Prompt
Develop a solution in Cpp to the problem described below:
Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j).
There is a lowercase English letter written in eac... |
### Prompt
Please create a solution in cpp to the following problem:
You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white.
You think that this pict... |
### Prompt
Please formulate a Cpp solution to the following problem:
Boris really likes numbers and even owns a small shop selling interesting numbers. He has n decimal numbers Bi. Cost of the number in his shop is equal to the sum of costs of its digits. You are given the values cd, where cd is the cost of the digit... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
problem
Given two strings, find the longest of the strings contained in both strings and write a program that answers that length.
Here, the string s included in the string t means that s appears consecutively in t. An empty string, that... |
### Prompt
Create a solution in CPP for the following problem:
Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag).
You are given an n × m grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is blank. The ... |
### Prompt
Develop a solution in Cpp to the problem described below:
Let's consider the following game. We have a rectangular field n × m in size. Some squares of the field contain chips.
Each chip has an arrow painted on it. Thus, each chip on the field points in one of the following directions: up, down, left or r... |
### Prompt
In cpp, your task is to solve the following problem:
Imp likes his plush toy a lot.
<image>
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copi... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of oper... |
### Prompt
Generate a Cpp solution to the following problem:
PolandBall has an undirected simple graph consisting of n vertices. Unfortunately, it has no edges. The graph is very sad because of that. PolandBall wanted to make it happier, adding some red edges. Then, he will add white edges in every remaining place. T... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You are given two lists of non-zero digits.
Let's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer?
In... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Problem A Secret of Chocolate Poles
Wendy, the master of a chocolate shop, is thinking of displaying poles of chocolate disks in the showcase. She can use three kinds of chocolate disks: white thin disks, dark thin disks, and dark thick disks... |
### Prompt
Your task is to create a CPP solution to the following problem:
A lot of students spend their winter holidays productively. Vlad has advanced very well in doing so! For three days already, fueled by salads and tangerines — the leftovers from New Year celebration — he has been calibrating his rating in his ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarp likes arithmetic progressions. A sequence [a_1, a_2, ..., a_n] is called an arithmetic progression if for each i (1 ≤ i < n) the value a_{i+1} - a_i is the same. For example, the sequences [42], [5, 5, 5], [2, 11, 20, 29] and [3, ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 ≤ li ≤ ri ≤ n) meaning that value <image> should be equal t... |
### Prompt
In cpp, your task is to solve the following problem:
We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.
Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a ca... |
### Prompt
Develop a solution in cpp to the problem described below:
Iahub does not like background stories, so he'll tell you exactly what this problem asks you for.
You are given a matrix a with n rows and n columns. Initially, all values of the matrix are zeros. Both rows and columns are 1-based, that is rows are... |
### Prompt
Develop a solution in cpp to the problem described below:
Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!
This contest consists of n problems, and Pasha solves ith problem in ai time units (his solutions a... |
### Prompt
Your task is to create a cpp solution to the following problem:
Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.
The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. S... |
### Prompt
Construct a Cpp code solution to the problem outlined:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
Constraints
* 1 ≤ a,b ≤ 10000
* a and b are integers.
Input
Input is given from Standard Input in the following format:
a b
Output
... |
### Prompt
Create a solution in Cpp for the following problem:
You are a coach of a group consisting of n students. The i-th student has programming skill a_i. All students have distinct programming skills. You want to divide them into teams in such a way that:
* No two students i and j such that |a_i - a_j| = 1 b... |
### Prompt
Construct a cpp code solution to the problem outlined:
This problem is about imaginary languages BHTML and BCSS, which slightly resemble HTML and CSS. Read the problem statement carefully as the resemblance is rather slight and the problem uses very simplified analogs.
You are given a BHTML document that ... |
### Prompt
Develop a solution in cpp to the problem described below:
There are N positive integers arranged in a circle.
Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation:
* Choose an integer i such that 1 \leq i \leq N.
* ... |
### Prompt
Create a solution in CPP for the following problem:
Molly Hooper has n different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The i-th of them has affection value ai.
Molly wants Sherlock to fall in love with her. She intends to do this by mixing a contiguous segmen... |
### Prompt
Please formulate a cpp solution to the following problem:
The Bitlandians are quite weird people. They have their own problems and their own solutions. They have their own thoughts and their own beliefs, they have their own values and their own merits. They have their own dishes and their own sausages!
In... |
### Prompt
In cpp, your task is to solve the following problem:
On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size.
There are N circular barriers deployed on the plane. The c... |
### Prompt
Generate a cpp solution to the following problem:
The evil Bumbershoot corporation produces clones for gruesome experiments in a vast underground lab. On one occasion, the corp cloned a boy Andryusha who was smarter than his comrades. Immediately Andryusha understood that something fishy was going on there... |
### Prompt
Create a solution in cpp for the following problem:
Easy and hard versions are actually different problems, so we advise you to read both statements carefully.
You are given a weighted rooted tree, vertex 1 is the root of this tree.
A tree is a connected graph without cycles. A rooted tree has a special ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Consider a road consisting of several rows. Each row is divided into several rectangular tiles, and all tiles in the same row are equal. The first row contains exactly one rectangular tile. Look at the picture below which shows how the til... |
### Prompt
Develop a solution in Cpp to the problem described below:
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the... |
### Prompt
Create a solution in cpp for the following problem:
Fibonacci numbers are the sequence of integers: f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, ..., fn = fn - 2 + fn - 1. So every next number is the sum of the previous two.
Bajtek has developed a nice way to compute Fibonacci numbers on a blackboard. ... |
### Prompt
Your task is to create a CPP solution to the following problem:
problem
At IOI Confectionery, rice crackers are baked using the traditional method since the company was founded. This traditional method is to bake the front side for a certain period of time with charcoal, turn it over when the front side i... |
### Prompt
Please create a solution in CPP to the following problem:
One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.
But there are too many problems, to do it manually. Alex asks you to w... |
### Prompt
In cpp, your task is to solve the following problem:
There are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N.
Takahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i on the i-th day. That is, on the i-t... |
### Prompt
Please formulate a Cpp solution to the following problem:
You are given an integer N.
Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.
If there are multiple solutions, any of them will be accepted.
Constraints
* It is guaranteed that, for the given integer N, there exists ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.