text stringlengths 424 69.5k |
|---|
### Prompt
Generate a Cpp solution to the following problem:
You are given an integer k and a tree T with n nodes (n is even).
Let dist(u, v) be the number of edges on the shortest path from node u to node v in T.
Let us define a undirected weighted complete graph G = (V, E) as following:
* V = \\{x β£ 1 β€ x β€ n... |
### Prompt
Create a solution in CPP for the following problem:
Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.
Constraints
* 1 β€ H β€ 300
* 1 β€ W β€ 300
Input
The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a sing... |
### Prompt
In cpp, your task is to solve the following problem:
You might have remembered Theatre square from the [problem 1A](https://codeforces.com/problemset/problem/1/A). Now it's finally getting repaved.
The square still has a rectangular shape of n Γ m meters. However, the picture is about to get more complica... |
### Prompt
Construct a cpp code solution to the problem outlined:
One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!
Why not make her own Codeforces, with blackjac... |
### Prompt
Generate a Cpp solution to the following problem:
There are N children, numbered 1, 2, ..., N.
Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.
For each i (1 \leq i \leq N), Child i will be happy if he/she gets exact... |
### Prompt
Develop a solution in Cpp to the problem described below:
One day a highly important task was commissioned to Vasya β writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he write... |
### Prompt
Develop a solution in CPP to the problem described below:
Borya has recently found a big electronic display. The computer that manages the display stores some integer number. The number has n decimal digits, the display shows the encoded version of the number, where each digit is shown using some lowercase... |
### Prompt
Construct a Cpp code solution to the problem outlined:
A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily 7 days!
In detail, she can choose any integer k which satisfies 1 β€ k β€ r, and set k d... |
### Prompt
Develop a solution in Cpp to the problem described below:
We will buy a product for N yen (the currency of Japan) at a shop.
If we use only 1000-yen bills to pay the price, how much change will we receive?
Assume we use the minimum number of bills required.
Constraints
* 1 \leq N \leq 10000
* N is an i... |
### Prompt
Please formulate a cpp solution to the following problem:
Given are N integers A_1,\ldots,A_N.
We will choose exactly K of these elements. Find the maximum possible product of the chosen elements.
Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).
Constra... |
### Prompt
Generate a CPP solution to the following problem:
Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red card.
Vasya is watching a r... |
### Prompt
Create a solution in CPP for the following problem:
There are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of time and will go to take boiled w... |
### Prompt
Your task is to create a cpp solution to the following problem:
Polycarp loves ciphers. He has invented his own cipher called Right-Left.
Right-Left cipher is used for strings. To encrypt the string s=s_{1}s_{2} ... s_{n} Polycarp uses the following algorithm:
* he writes down s_1,
* he appends the ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a string t consisting of n lowercase Latin letters and an integer number k.
Let's define a substring of some string s with indices from l to r as s[l ... r].
Your task is to construct such string s of minimum possible lengt... |
### Prompt
Your task is to create a CPP solution to the following problem:
You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca"... |
### Prompt
Please create a solution in cpp to the following problem:
Akari has n kinds of flowers, one of each kind.
She is going to choose one or more of these flowers to make a bouquet.
However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.
How many different bouquets a... |
### Prompt
Develop a solution in cpp to the problem described below:
This problem is interactive.
You should guess hidden number x which is between 1 and M = 10004205361450474, inclusive.
You could use up to 5 queries.
In each query, you can output an increasing sequence of k β€ x integers, each between 1 and M, in... |
### Prompt
In CPP, your task is to solve the following problem:
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start... |
### Prompt
Please formulate a CPP solution to the following problem:
To get on the Shinkansen, you need two tickets, a "ticket" and a "limited express ticket". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen, one ticket can be used as both ... |
### Prompt
Create a solution in CPP for the following problem:
You are given two strings s and t consisting of lowercase Latin letters. The length of t is 2 (i.e. this string consists only of two characters).
In one move, you can choose any character of s and replace it with any lowercase Latin letter. More formally... |
### Prompt
Create a solution in cpp for the following problem:
There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling.
There is a deck of n cards. Starting from the p-th card from the top of t... |
### Prompt
Develop a solution in CPP to the problem described below:
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all the houses were built in one row.
Let's enumerate all the houses from left to right, starting with one. A house is considered to be ... |
### Prompt
In cpp, your task is to solve the following problem:
Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!
The only thing Mrs. Smith remembered was that any permutation of n can be a secret phone number. Only those permutations that minimize secret value might be... |
### Prompt
In CPP, your task is to solve the following problem:
For a given prime integer p and integers Ξ±, A calculate the number of pairs of integers (n, k), such that 0 β€ k β€ n β€ A and <image> is divisible by pΞ±.
As the answer can be rather large, print the remainder of the answer moduly 109 + 7.
Let us remind ... |
### Prompt
In CPP, your task is to solve the following problem:
Egor is a famous Russian singer, rapper, actor and blogger, and finally he decided to give a concert in the sunny Republic of Dagestan.
There are n cities in the republic, some of them are connected by m directed roads without any additional conditions.... |
### Prompt
Please formulate a CPP solution to the following problem:
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Joisino is planning to record N TV programs with recorders.
The TV can receive C channels numbered 1 through C.
The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel... |
### Prompt
Develop a solution in cpp to the problem described below:
In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.
For example, for n = 4 the sum is equal to - 1 - 2 + 3 - 4 = - 4, because 1, 2 and 4 are 20, 21 and 22 respectiv... |
### Prompt
Your task is to create a CPP solution to the following problem:
Masha has n types of tiles of size 2 Γ 2. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.
Masha decides to construct the square of size m Γ m consisting of the given tiles. This square also has ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
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
Your challenge is to write a cpp solution to the following problem:
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.
There are n + 1 cities conse... |
### Prompt
Develop a solution in cpp to the problem described below:
You are given an integer n.
You should find a list of pairs (x_1, y_1), (x_2, y_2), ..., (x_q, y_q) (1 β€ x_i, y_i β€ n) satisfying the following condition.
Let's consider some function f: N Γ N β N (we define N as the set of positive integers). In ... |
### Prompt
Construct a CPP code solution to the problem outlined:
You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i β€ n) holds ci β€ ci - 1.
Let's denote s as the total number of cells of table a, that is, <image>. We know that each c... |
### Prompt
Please create a solution in cpp to the following problem:
Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each ... |
### Prompt
Your task is to create a cpp solution to the following problem:
"Eat a beaver, save a tree!" β That will be the motto of ecologists' urgent meeting in Beaverley Hills.
And the whole point is that the population of beavers on the Earth has reached incredible sizes! Each day their number increases in severa... |
### Prompt
Generate a Cpp solution to the following problem:
You are given four integers: H, W, h and w (1 β€ h β€ H, 1 β€ w β€ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:
* The matrix has H rows and W columns.
*... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
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 can be any letter from the first 20 lowercase letters of English alphabet (read statement for be... |
### Prompt
Your task is to create a CPP solution to the following problem:
You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.
A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element... |
### Prompt
Generate a cpp solution to the following problem:
Aoki loves numerical sequences and trees.
One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree.
Aoki wants to construct a tree with N vertices numbered 1 through N, such that for each i =... |
### Prompt
Generate a CPP solution to the following problem:
[Γ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......
It's ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Greg has an array a = a1, a2, ..., an and m operations. Each operation looks as: li, ri, di, (1 β€ li β€ ri β€ n). To apply operation i to the array means to increase all array elements with numbers li, li + 1, ..., ri by value di.
Greg wrot... |
### Prompt
Create a solution in CPP for the following problem:
A subway scheme, classic for all Berland cities is represented by a set of n stations connected by n passages, each of which connects exactly two stations and does not pass through any others. Besides, in the classic scheme one can get from any station to... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
In the good old days, the Internet was free from fears and terrorism. People did not have to worry about any cyber criminals or mad computer scientists. Today, however, you are facing atrocious crackers wherever you are, unless being disco... |
### 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 edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = `W` represents the vertex is white; c_i = `B`... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Someone give a strange birthday present to Ivan. It is hedgehog β connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring a... |
### Prompt
Construct a CPP code solution to the problem outlined:
You are given a description of a depot. It is a rectangular checkered field of n Γ m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").
You have one bomb. If you lay the bomb at the cell (x, y), then after triggering... |
### Prompt
Develop a solution in CPP to the problem described below:
Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.
That element... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given n strings s1, s2, ..., sn consisting of characters 0 and 1. m operations are performed, on each of them you concatenate two existing strings into a new one. On the i-th operation the concatenation saisbi is saved into a new string sn +... |
### Prompt
In CPP, your task is to solve the following problem:
Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm!
... |
### Prompt
In CPP, your task is to solve the following problem:
Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible.
Help Petya to split the integers. Each of n integers s... |
### Prompt
Please formulate a cpp solution to the following problem:
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below:
1. Let i be the smallest index such that t_i = t_{i + 1}. If su... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if <image> and <image>, where k is some integer ... |
### Prompt
Your task is to create a CPP solution to the following problem:
The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates... |
### Prompt
Develop a solution in cpp to the problem described below:
There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β the athlete number i has the strength s_i.
You want to split all athletes into two teams. Each team must have at lea... |
### Prompt
Construct a CPP code solution to the problem outlined:
Watto, the owner of a spare parts store, has recently got an order for the mechanism that can process strings in a certain way. Initially the memory of the mechanism is filled with n strings. Then the mechanism should be able to process queries of the ... |
### Prompt
Please formulate a cpp solution to the following problem:
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 β€ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 β€ u, v < N), we define the distance d(u, v) as the number of edges in the... |
### Prompt
Develop a solution in CPP to the problem described below:
Pushok the dog has been chasing Imp for a few hours already.
<image>
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string t consisting of letters 's' and 'h', that produces a lot of n... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given an array a consisting of n integer numbers.
You have to color this array in k colors in such a way that:
* Each element of the array should be colored in some color;
* For each i from 1 to k there should be at least o... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Let's call an integer array a_1, a_2, ..., a_n good if a_i β i for each i.
Let F(a) be the number of pairs (i, j) (1 β€ i < j β€ n) such that a_i + a_j = i + j.
Let's say that an array a_1, a_2, ..., a_n is excellent if:
* a is good;
... |
### Prompt
Generate a cpp solution to the following problem:
You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.
For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .... The 7-th number among them is 10.
In... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions:
* After the cutting each ribbon piece should have length a, b or c.
* After the cutting the number of ribbon pi... |
### Prompt
Create a solution in CPP for the following problem:
Description
THE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this mont... |
### Prompt
Please create a solution in CPP to the following problem:
Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us ... |
### Prompt
In CPP, your task is to solve the following problem:
We get more and more news about DDoS-attacks of popular websites.
Arseny is an admin and he thinks that a website is under a DDoS-attack if the total number of requests for a some period of time exceeds 100 β
t, where t β the number of seconds in this t... |
### Prompt
Develop a solution in cpp to the problem described below:
Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:
\begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1... |
### Prompt
Develop a solution in Cpp to the problem described below:
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.
The i-th (1β€iβ€M) edge connects vertex a_i and vertex b_i with a distance of c_i.
Here, a self-loop is an edge where a... |
### Prompt
Please formulate a cpp solution to the following problem:
For a given array a consisting of n integers and a given integer m find if it is possible to reorder elements of the array a in such a way that β_{i=1}^{n}{β_{j=i}^{n}{(a_j)/(j)}} equals m? It is forbidden to delete elements as well as insert new el... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:
Max owns n creatures, i-th of them can be describ... |
### Prompt
Your task is to create a CPP solution to the following problem:
A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.
Constraints
* 1 β€ |V| β€ 10,000
* 0 β€ |E| ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Consider the function p(x), where x is an array of m integers, which returns an array y consisting of m + 1 integers such that yi is equal to the sum of first i elements of array x (0 β€ i β€ m).
You have an infinite sequence of arrays A0, A1, ... |
### Prompt
Develop a solution in CPP to the problem described below:
You have two variables a and b. Consider the following sequence of actions performed with these variables:
1. If a = 0 or b = 0, end the process. Otherwise, go to step 2;
2. If a β₯ 2Β·b, then set the value of a to a - 2Β·b, and repeat step 1. Oth... |
### Prompt
In Cpp, your task is to solve the following problem:
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.
A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.
The deck of cards is represented by a string as fo... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
In Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a, b) is the smallest positive integer x which is divisible by both a and b.
Omkar, having a laudably curious mind, immediately thought of a problem in... |
### Prompt
Construct a CPP code solution to the problem outlined:
Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers from 1 to m.
Public transport ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
As Gerald sets the table, Alexander sends the greeting cards, and Sergey and his twins create an army of clone snowmen, Gennady writes a New Year contest.
The New Year contest begins at 18:00 (6.00 P.M.) on December 31 and ends at 6:00 (6.00 A.M.) on ... |
### Prompt
Create a solution in cpp for the following problem:
I decided to create a program that displays a "round and round pattern". The "round and round pattern" is as follows.
* If the length of one side is n, it is displayed as a character string with n rows and n columns.
* A spiral pattern that rotates clock... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Barney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the tree is the city ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):
* Choose a pair of integers i, j (1\leq i < j\leq |S|) such that... |
### Prompt
Create a solution in cpp for the following problem:
Two beavers, Timur and Marsel, play the following game.
There are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length of each... |
### Prompt
Create a solution in Cpp for the following problem:
There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.
Snuke will perform the following operation zero or more times:
* Choose two stones painted in the same color. Repaint all the stones between them, with the c... |
### Prompt
Create a solution in Cpp for the following problem:
You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of:
* Operation AND ('&', ASCII code 38)
* Operation ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Input
The input contains two integers N, M (1 β€ N β€ 1024, 2 β€ M β€ 16), separated by a single space.
Output
Output "YES" or "NO".
Examples
Input
2 3
Output
YES
Input
3 2
Output
NO
Input
33 16
Output
YES
Input
26... |
### Prompt
Please formulate a Cpp solution to the following problem:
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the arr... |
### Prompt
Generate a CPP solution to the following problem:
You are a given a list of integers a_1, a_2, β¦, a_n and s of its segments [l_j; r_j] (where 1 β€ l_j β€ r_j β€ n).
You need to select exactly m segments in such a way that the k-th order statistic of the multiset of a_i, where i is contained in at least one s... |
### Prompt
Please create a solution in cpp 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). You... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe can be connected t... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Karen is getting ready for a new school day!
<image>
It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.
What is the min... |
### Prompt
Please provide a CPP coded solution to the problem described below:
All Berland residents are waiting for an unprecedented tour of wizard in his Blue Helicopter over the cities of Berland!
It is well-known that there are n cities in Berland, some pairs of which are connected by bidirectional roads. Each p... |
### Prompt
In cpp, your task is to solve the following problem:
An atom of element X can exist in n distinct states with energies E1 < E2 < ... < En. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are select... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if
1. the sequence consists of at least two elements
2. f0 and f1 are arbitrary
3. fn + 2 = fn + 1 + fn for all n β₯... |
### Prompt
Please create a solution in Cpp to the following problem:
You are running for a governor in a small city in Russia. You ran some polls and did some research, and for every person in the city you know whom he will vote for, and how much it will cost to bribe that person to vote for you instead of whomever h... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Takahashi has many red balls and blue balls. Now, he will place them in a row.
Initially, there is no ball placed.
Takahashi, who is very patient, will do the following operation 10^{100} times:
* Place A blue balls at the end of the ro... |
### Prompt
Please create a solution in cpp to the following problem:
wHAT DO WE NEED cAPS LOCK FOR?
Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default. If it is pressed by accident, it leads to accidents like the one we had in the first passage.
Let's... |
### Prompt
Your task is to create a cpp solution to the following problem:
Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex cover problem very interesting.
Suppose the graph G is given. Subset A of its vertices is called a vertex cover of this graph, if for each edge... |
### Prompt
Develop a solution in CPP to the problem described below:
You are given an array a of n points in k-dimensional space. Let the distance between two points a_x and a_y be β _{i = 1}^{k} |a_{x, i} - a_{y, i}| (it is also known as Manhattan distance).
You have to process q queries of the following two types:... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.
Vasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom, of course, wants to give him as... |
### Prompt
Generate a CPP solution to the following problem:
In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must.
Little Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this...
Given two integers p and k, find... |
### Prompt
Construct a cpp code solution to the problem outlined:
One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.
Then, by using a random generator they choose a random integer... |
### Prompt
Please formulate a CPP solution to the following problem:
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has a number consisting... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.