text stringlengths 424 69.5k |
|---|
### Prompt
Develop a solution in Cpp to the problem described below:
Hanh is a famous biologist. He loves growing trees and doing experiments on his own garden.
One day, he got a tree consisting of n vertices. Vertices are numbered from 1 to n. A tree with n vertices is an undirected connected graph with n-1 edges. ... |
### Prompt
Please create a solution in CPP to the following problem:
You have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.
Your objective is to use some of these bamboos (possibly all) to obtain three bamboos of length A, B, C. For that, you can use the following three kinds... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together.
Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed ... |
### Prompt
Please formulate a CPP solution to the following problem:
Salem gave you n sticks with integer positive lengths a_1, a_2, …, a_n.
For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from a to b is |... |
### Prompt
Construct a CPP code solution to the problem outlined:
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B. Find out which store is close... |
### Prompt
Develop a solution in Cpp to the problem described below:
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 exactl... |
### Prompt
Generate a Cpp solution to the following problem:
Two people play the following string game. Initially the players have got some string s. The players move in turns, the player who cannot make a move loses.
Before the game began, the string is written on a piece of paper, one letter per cell.
<image> An... |
### Prompt
Please create a solution in CPP to the following problem:
Little Paul wants to learn how to play piano. He already has a melody he wants to start with. For simplicity he represented this melody as a sequence a_1, a_2, …, a_n of key numbers: the more a number is, the closer it is to the right end of the pia... |
### Prompt
In Cpp, your task is to solve the following problem:
Takahashi the Jumbo will practice golf.
His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).
If he can achieve the objective, print `OK`; if he cannot, print `NG`.
Co... |
### Prompt
Construct a CPP code solution to the problem outlined:
Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2... |
### Prompt
Generate a cpp solution to the following problem:
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good numb... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
There are n shovels in Polycarp's shop. The i-th shovel costs i burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs.
Visit... |
### Prompt
Create a solution in cpp for the following problem:
In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.
In this problem, ... |
### Prompt
Create a solution in CPP for the following problem:
Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for exactly c seconds, starting one second after the abilit... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
A and B are preparing themselves for programming contests.
After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.
A... |
### Prompt
In CPP, your task is to solve the following problem:
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exactly k of the n... |
### Prompt
Generate a cpp solution to the following problem:
For his computer science class, Jacob builds a model tree with sticks and balls containing n nodes in the shape of a tree. Jacob has spent ai minutes building the i-th ball in the tree.
Jacob's teacher will evaluate his model and grade Jacob based on the e... |
### Prompt
Develop a solution in CPP to the problem described below:
Shrimpy Duc is a fat and greedy boy who is always hungry. After a while of searching for food to satisfy his never-ending hunger, Shrimpy Duc finds M&M candies lying unguarded on a L × L grid. There are n M&M candies on the grid, the i-th M&M is cur... |
### Prompt
Construct a CPP code solution to the problem outlined:
Old MacDonald has a farm and a large potato field, (1010 + 1) × (1010 + 1) square meters in size. The field is divided into square garden beds, each bed takes up one square meter.
Old McDonald knows that the Colorado potato beetle is about to invade h... |
### Prompt
Construct a Cpp code solution to the problem outlined:
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.
You have n... |
### Prompt
In cpp, your task is to solve the following problem:
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
Constraints
* 0 < a, b ≤ 2,000,000,000
* LCM(a, b) ≤ 2,000,000,000
* The number of data sets ≤ 50
Input
Input consists of several d... |
### Prompt
Develop a solution in Cpp to the problem described below:
Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities of Berland were connected by n two-way road... |
### Prompt
Please create a solution in Cpp to the following problem:
The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arr... |
### Prompt
Please provide a cpp coded solution to the problem described below:
There is a simple undirected graph with N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects Vertex U_i and V_i. Also, Vertex i has two predetermined integers A_i and B_i. Y... |
### Prompt
Create a solution in Cpp for the following problem:
Alice wants to send an important message to Bob. Message a = (a1, ..., an) is a sequence of positive integers (characters).
To compress the message Alice wants to use binary Huffman coding. We recall that binary Huffman code, or binary prefix code is a f... |
### Prompt
In CPP, your task is to solve the following problem:
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one str... |
### Prompt
In Cpp, your task is to solve the following problem:
A class of students wrote a multiple-choice test.
There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question ... |
### Prompt
Create a solution in Cpp for the following problem:
Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play... |
### Prompt
Develop a solution in cpp to the problem described below:
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly,... |
### Prompt
Construct a cpp code solution to the problem outlined:
Draw a frame which has a height of H cm and a width of W cm. For example, the following figure shows a frame which has a height of 6 cm and a width of 10 cm.
........#
........#
........#
........#
Constraints
* 3 ≤ H ≤ 300
* 3 ≤ W ≤ 300
Input
... |
### Prompt
Create a solution in Cpp for the following problem:
Given are a positive integer N and a string S of length N consisting of lowercase English letters.
Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
Constrai... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
It's now 260 AD. Shapur, being extremely smart, became the King of Persia. He is now called Shapur, His majesty King of kings of Iran and Aniran.
Recently the Romans declared war on Persia. They dreamed to occupy Armenia. In the recent wa... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a directed graph with N vertices and M edges. The vertices are numbered 1, 2, ..., N, and the edges are numbered 1, 2, ..., M. Edge i points from Vertex a_i to Vertex b_i.
For each edge, determine whether the reversion of th... |
### Prompt
Your task is to create a CPP solution to the following problem:
E: Binary Sequence-Binary Sequence-
story
I love binaries Bonald.Brvin.Bnuth! He is known as Uncle Bnuth, who is studying the nature of binary sequences at Offtunford University! By the way, if my name "Bonald.Brvin.Bnuth" is binarized from ... |
### Prompt
Generate a Cpp solution to the following problem:
Programmer Sasha is a student at MIPT (Moscow Institute of Physics and Technology) and he needs to make a laboratory work to pass his finals.
A laboratory unit is a plane with standard coordinate axes marked on it. Physicists from Moscow Institute of Physi... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Let's define a function f(x) (x is a positive integer) as follows: write all digits of the decimal representation of x backwards, then get rid of the leading zeroes. For example, f(321) = 123, f(120) = 21, f(1000000) = 1, f(111) = 111.
Let's ... |
### Prompt
Generate a Cpp solution to the following problem:
There are n students who have taken part in an olympiad. Now it's time to award the students.
Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But... |
### Prompt
In Cpp, your task is to solve the following problem:
For two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies the following:
* The p_i-th element (1 \leq i \leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q.
You... |
### Prompt
Create a solution in CPP for the following problem:
Alice and Bob are going to celebrate Christmas by playing a game with a tree of presents. The tree has n nodes (numbered 1 to n, with some node r as its root). There are a_i presents are hanging from the i-th node.
Before beginning the game, a special in... |
### Prompt
Generate a CPP solution to the following problem:
In computer science, there is a method called "Divide And Conquer By Node" to solve some hard problems about paths on a tree. Let's desribe how this method works by function:
solve(t) (t is a tree):
1. Chose a node x (it's common to chose weight-center... |
### Prompt
Generate a cpp solution 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 finish on... |
### Prompt
Construct a Cpp code solution to the problem outlined:
We have a grid with N rows and N columns. The cell at the i-th row and j-th column is denoted (i, j).
Initially, M of the cells are painted black, and all other cells are white. Specifically, the cells (a_1, b_1), (a_2, b_2), ..., (a_M, b_M) are paint... |
### Prompt
Create a solution in Cpp for the following problem:
Example
Input
ACM
Output
0
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
pair<string, string> split(const... |
### Prompt
Please create a solution in Cpp to the following problem:
Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about ... |
### Prompt
Please create a solution in CPP to the following problem:
In this problem you will meet the simplified model of game Pudding Monsters.
An important process in developing any game is creating levels. A game field in Pudding Monsters is an n × n rectangular grid, n of its cells contain monsters and some oth... |
### Prompt
In CPP, your task is to solve the following problem:
Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.
To improve his division skills, Oleg came up with t pairs of integers p_i and q_i and for each pair decided to find the greatest integer x_i, such that:
... |
### Prompt
In Cpp, your task is to solve the following problem:
Give you N cards. Only one natural number is written on each card. However, the same number is never written.
From now on, as a question, I will say an appropriate natural number. Please answer the largest remainder you get when you divide the number on... |
### Prompt
Develop a solution in CPP to the problem described below:
When Petya has free from computer games time, he attends university classes. Every day the lessons on Petya’s faculty consist of two double classes. The floor where the lessons take place is a long corridor with M classrooms numbered from 1 to M, si... |
### Prompt
Create a solution in CPP for the following problem:
problem
JOI Pizza sells pizza home delivery along the d-meter-long ring road that runs through the city center.
JOI Pizza has n stores S1, ..., Sn on the loop line. The head office is S1. The distance from S1 to Si when moving the loop line clockwise is... |
### Prompt
Please create a solution in CPP to the following problem:
In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.
In Taknese, the plural form of a noun is spelled based on the following rules:
* If a noun's singular form does not end with `s`, append `s` to ... |
### Prompt
Develop a solution in CPP to the problem described below:
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curs... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Farmer John is hosting a tennis tournament with his n cows. Each cow has a skill level si, and no two cows having the same skill level. Every cow plays every other cow exactly once in the tournament, and each cow beats every cow with skill... |
### Prompt
In CPP, your task is to solve the following problem:
Everything red frightens Nian the monster. So do red paper and... you, red on Codeforces, potential or real.
Big Banban has got a piece of paper with endless lattice points, where lattice points form squares with the same area. His most favorite closed ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Due to atheistic Soviet past, Christmas wasn't officially celebrated in Russia for most of the twentieth century. As a result, the Russian traditions for Christmas and New Year mixed into one event celebrated on the New Year but including ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
You have a simple undirected graph consisting of n vertices and m edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let v_1 an... |
### Prompt
Generate a CPP solution to the following problem:
Petya likes horse racing very much. Horses numbered from l to r take part in the races. Petya wants to evaluate the probability of victory; for some reason, to do that he needs to know the amount of nearly lucky horses' numbers. A nearly lucky number is an ... |
### Prompt
Your challenge is to write 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 d... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
A top-secret military base under the command of Colonel Zuev is expecting an inspection from the Ministry of Defence. According to the charter, each top-secret military base must include a top-secret troop that should... well, we cannot te... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
There is a grid of squares with H+1 horizontal rows and W vertical columns.
You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down... |
### Prompt
Please create a solution in Cpp to the following problem:
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of English ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
This is an easier version of the problem. In this version, n ≤ 2000.
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 ... |
### Prompt
Please formulate a CPP solution to the following problem:
A calculator scholar has discovered a strange life form called an electronic fly that lives in electronic space. While observing the behavior of the electronic flies, the electronic flies at the (x, y, z) point in this space then move to (x', y', z'... |
### Prompt
Develop a solution in cpp to the problem described below:
Vasya owns three strings s , a and b, each of them consists only of first k Latin letters.
Let a template be such a string of length k that each of the first k Latin letters appears in it exactly once (thus there are k! distinct templates). Applica... |
### Prompt
Please formulate a CPP solution to the following problem:
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his friends b... |
### Prompt
Please formulate a CPP solution to the following problem:
Levko loves sports pathfinding competitions in his city very much. In order to boost his performance, Levko spends his spare time practicing. The practice is a game.
The city consists of n intersections connected by m + k directed roads. Two or mor... |
### Prompt
Your task is to create a CPP solution to the following problem:
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:
* the Power Gem of purple color,
* the Time Gem of green color,
* the Space Gem of blue color,
* the Soul Gem of orange co... |
### Prompt
Develop a solution in Cpp to the problem described below:
problem
Information I want to paint a rectangular veneer board to make a signboard for the promotion of the Olympic Games. Some rectangular masking tapes are pre-attached to the veneer board where I do not want to paint. We decided to paint each ar... |
### Prompt
Generate a CPP solution to the following problem:
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part... |
### Prompt
Construct a CPP code solution to the problem outlined:
Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge [1;m] segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs e... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.
Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the army should consist of some subset of them.
The ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are ... |
### Prompt
In cpp, your task is to solve the following problem:
Taro is an elementary school student and has graffiti on the back of the leaflet. At one point, Taro came up with the next game.
* Write n × n grid-like squares.
* The initial state of each square is either marked or unmarked.
* Erase or write these cir... |
### Prompt
Please provide a cpp coded solution to the problem described below:
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course,... |
### Prompt
Create a solution in Cpp for the following problem:
A state with $n$ flags of ON or OFF can be represented by a sequence of bits where $0, 1, ..., n-1$ th flag corresponds to 1 (ON) or 0 (OFF). The state can be managed by the corresponding decimal integer, because the sequence of bits is a binary represent... |
### Prompt
Create a solution in cpp for the following problem:
Igor likes hexadecimal notation and considers positive integer in the hexadecimal notation interesting if each digit and each letter in it appears no more than t times. For example, if t = 3, then integers 13a13322, aaa, abcdef0123456789 are interesting, ... |
### Prompt
Construct a CPP code solution to the problem outlined:
A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of ... |
### Prompt
Please formulate a cpp solution to the following problem:
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
Create a solution in cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
### Prompt
Please create a solution in cpp to the following problem:
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
Please create a solution in Cpp to the following problem:
Example
Input
2
10 10
Output
40.00000000
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using vi = vector<int>;
using ll = lo... |
### Prompt
Please create a solution in Cpp to the following problem:
Tree is a connected graph without cycles. A leaf of a tree is any vertex connected with exactly one other vertex.
You are given a tree with n vertices and a root in the vertex 1. There is an ant in each leaf of the tree. In one second some ants can... |
### Prompt
Develop a solution in Cpp to the problem described below:
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, suc... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS... |
### Prompt
Create a solution in Cpp for the following problem:
A rabbit who came to the fair found that the prize for a game at a store was a carrot cake. The rules for this game are as follows.
There is a grid-like field of vertical h squares x horizontal w squares, and each block has at most one block. Each block ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
There are n students living in the campus. Every morning all students wake up at the same time and go to wash. There are m rooms with wash basins. The i-th of these rooms contains ai wash basins. Every student independently select one the ... |
### Prompt
Please create a solution in CPP to the following problem:
Given are strings s and t of length N each, both consisting of lowercase English letters.
Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the secon... |
### Prompt
Please formulate a CPP solution to the following problem:
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.
Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.
Find the inversion number of B, modulo ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Vasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present — the clock that shows not only the time, but also the date.
The clock's face can display any number from 1 to d. It is gua... |
### Prompt
Generate a CPP solution to the following problem:
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the rig... |
### Prompt
Your task is to create a CPP solution to the following problem:
We'll call string s[a, b] = sasa + 1... sb (1 ≤ a ≤ b ≤ |s|) a substring of string s = s1s2... s|s|, where |s| is the length of string s.
The trace of a non-empty string t is a set of characters that the string consists of. For example, the t... |
### Prompt
Generate a cpp solution to the following problem:
The only difference between easy and hard versions is constraints.
The BerTV channel every day broadcasts one episode of one of the k TV shows. You know the schedule for the next n days: a sequence of integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ k), where a_i is... |
### Prompt
Please formulate a Cpp solution to the following problem:
N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals.
The preliminary stage consists of several rounds, which will take place as fol... |
### Prompt
In cpp, your task is to solve the following problem:
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of... |
### Prompt
Please create a solution in Cpp to the following problem:
Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help hi... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
We all know the problem about the number of ways one can tile a 2 × n field by 1 × 2 dominoes. You probably remember that it goes down to Fibonacci numbers. We will talk about some other problem below, there you also are going to deal with... |
### Prompt
Develop a solution in Cpp to the problem described below:
Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N?
Constraints
* 2 \leq N \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
... |
### Prompt
Develop a solution in Cpp to the problem described below:
Simon has a rectangular table consisting of n rows and m columns. Simon numbered the rows of the table from top to bottom starting from one and the columns — from left to right starting from one. We'll represent the cell on the x-th row and the y-th... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build... |
### Prompt
Create a solution in cpp for the following problem:
Some company is going to hold a fair in Byteland. There are n towns in Byteland and m two-way roads between towns. Of course, you can reach any town from any other town using roads.
There are k types of goods produced in Byteland and every town produces ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n → R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.