task stringlengths 0 154k | __index_level_0__ int64 0 39.2k |
|---|---|
Luba needs your help again! Luba has n TV sets. She knows that i-th TV set will be working from moment of time li till moment ri, inclusive.
Luba wants to switch off one of TV sets in order to free the socket. Let's call some TV set redundant if after switching it off the number of integer moments of time when at leas... | 24,200 |
Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up with such a problem.
You are given an array a consisting of n positive integers and queries to it. The queries can be of two types:
1. Make a unit cyclic shift to the right on the segmen... | 24,201 |
Chandu is a very strict mentor. He always gives a lot of work to his interns. So his interns decided to kill him. There is a party in the office on Saturday Night, and the interns decided to kill him on the same day. In the party, there are N beer bottles. Each bottle has a integer X written on it. Interns decided to m... | 24,202 |
Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.
King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordina... | 24,203 |
As you all know, Sansa is trying to escape from the Boltons' specially from Ramsey!
Winterfell is divided in an straight line of ice. In the line, each block has some thickness value. Ramsey would catch Sansa and Theon in an interval of ice if the XOR of all thickness of ice in that interval is greater than some valu... | 24,204 |
Gottfried learned about binary number representation. He then came up with this task and presented it to you.
You are given a collection of n non-negative integers a_1, β¦, a_n. You are allowed to perform the following operation: choose two distinct indices 1 β€ i, j β€ n. If before the operation a_i = x, a_j = y, then a... | 24,205 |
Rohit dreams he is in a shop with an infinite amount of marbles. He is allowed to select n marbles. There are marbles of k different colors. From each color there are also infinitely many marbles. Rohit wants to have at least one marble of each color, but still there are a lot of possibilities for his selection. In his... | 24,206 |
Let's define a balanced multiset the following way. Write down the sum of all elements of the multiset in its decimal representation. For each position of that number check if the multiset includes at least one element such that the digit of the element and the digit of the sum at that position are the same. If that ho... | 24,207 |
F: Disordered Data Detection / Anomaly detection
story
Akane Miyamori is an engineer working for Musashino Software. Today, I'm worried about the bug report I received from the customer. "Weird story, the behavior of the software you made last time is plump, can you check it there? Isn't it your job to maintain it?" ... | 24,208 |
Problem description.
Liza wants to share her pizza among n friends, What are the minimum number of straight knife strokes required to cut the pizza into n pieces?
Input
The first line contains number of test cases T.
The next T lines contain the input numbers N, the numbers of pieces required.
Output
For each tes... | 24,209 |
You are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction <image> whose denominator is no more than n.
Formally, you should find such pair of integers a, b (1 β€ b β€ n; 0 β€ a) that the value <image> is as minimal as possible.
If there are multiple "nearest" fractions, choose... | 24,210 |
"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." β an excerpt from contest rules.
A total of n participants took part in the contest (n β₯ k), and you already know their scores. Calculate how many ... | 24,211 |
Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ a.
What is the least number of flagstones needed to pave the Square? It'... | 24,212 |
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.
Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if t... | 24,213 |
You are given n integers a1, a2, ..., an.
A sequence of integers x1, x2, ..., xk is called a "xor-sequence" if for every 1 β€ i β€ k - 1 the number of ones in the binary representation of the number xi <image> xi + 1's is a multiple of 3 and <image> for all 1 β€ i β€ k. The symbol <image> is used for the binary exclusive ... | 24,214 |
D --Disciple Life is Hard / Disciple is hard
Story
The person in D loves donuts. I always want donuts. However, D, who was ordered by his master, Bunashimejitan, to train himself, must limit his calorie intake. Therefore, D person decided to eat donuts up to the calories burned by the training that day, considering t... | 24,215 |
It's Piegirl's birthday soon, and Pieguy has decided to buy her a bouquet of flowers and a basket of chocolates.
The flower shop has F different types of flowers available. The i-th type of flower always has exactly pi petals. Pieguy has decided to buy a bouquet consisting of exactly N flowers. He may buy the same typ... | 24,216 |
You have an array a_1, a_2, ..., a_n.
Let's call some subarray a_l, a_{l + 1}, ... , a_r of this array a subpermutation if it contains all integers from 1 to r-l+1 exactly once. For example, array a = [2, 2, 1, 3, 2, 3, 1] contains 6 subarrays which are subpermutations: [a_2 ... a_3], [a_2 ... a_4], [a_3 ... a_3], [a... | 24,217 |
It is dark times in Berland. Berlyand opposition, funded from a neighboring state, has organized a demonstration in Berland capital Bertown. Through the work of intelligence we know that the demonstrations are planned to last for k days.
Fortunately, Berland has a special police unit, which can save the country. It ha... | 24,218 |
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.
Input
The first line contains an integer t (1 β€ t β€ 1000) β the ... | 24,219 |
My flatmate, Sayan, once invited all his relatives and friends from all over the city to join him on his birthday party.
He is also famous for boasting that all his friends and relatives belong to "proper" families.
Now, he appointed a gaurd to allow only his relatives and friends into the party.
It is gauranteed that ... | 24,220 |
Mr. Tanaka died leaving the orchard of HW Earl. The orchard is divided into H x W plots in the north, south, east, and west directions, and apples, oysters, and oranges are planted in each plot. Mr. Tanaka left such a will.
Divide the orchard into as many relatives as possible on a parcel basis. However, if the same k... | 24,221 |
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 β₯ 0.
You are given some sequence of integers a1, a2, ..., an. Your task is... | 24,222 |
Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 β€ i β€ n.
Some mirrors are called checkpoints. Initially, only the 1st mirror is a checkpoint. It remains a checkpoint ... | 24,223 |
Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.
Valera absolutel... | 24,224 |
After learning about polynomial hashing, Heidi decided to learn about shift-xor hashing. In particular, she came across this interesting problem.
Given a bitstring y β \{0,1\}^n find out the number of different k (0 β€ k < n) such that there exists x β \{0,1\}^n for which y = x β \mbox{shift}^k(x).
In the above, β is ... | 24,225 |
Your classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: s of length n and t of length m.
A sequence p_1, p_2, β¦, p_m, where 1 β€ p_1 < p_2 < β¦ < p_m β€ n, is called beautiful, if s_{p_i} = t_i for all i from 1 to m. The width of a sequence is defined as max_{1 ... | 24,226 |
Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,..., 10" will be corrected to... | 24,227 |
Vova's house is an array consisting of n elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The i-th element of the array is 1 if there is a heater in the position i, otherwise the i-th element of the array is 0.
Each heater has a va... | 24,228 |
This is an interactive problem.
Kochiya Sanae is playing with magnets. Realizing that some of those magnets are demagnetized, she is curious to find them out.
There are n magnets, which can be of the following 3 types:
* N
* S
* - β these magnets are demagnetized.
Note that you don't know the types of these... | 24,229 |
Have you ever tried to explain to the coordinator, why it is eight hours to the contest and not a single problem has been prepared yet? Misha had. And this time he has a really strong excuse: he faced a space-time paradox! Space and time replaced each other.
The entire universe turned into an enormous clock face with ... | 24,230 |
Dreamoon likes strings. Today he created a game about strings:
String s_1, s_2, β¦, s_n is beautiful if and only if for each 1 β€ i < n, s_i β s_{i+1}.
Initially, Dreamoon has a string a. In each step Dreamoon can choose a beautiful substring of a and remove it. Then he should concatenate the remaining characters (in t... | 24,231 |
You are given a huge integer a consisting of n digits (n is between 1 and 3 β
10^5, inclusive). It may contain leading zeros.
You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by 2).
For example, if a = 032... | 24,232 |
Prats is learning to count.But this is not a usual counting.He has been given the task to count number of trailing 0s in a binary representation of a number.
Β
Input
First line of input contains T, number of test cases. Each of the next T lines contains a number N.
Β
Output
Output the number of trailing 0s in binary ... | 24,233 |
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.
One more t... | 24,234 |
Bizon the Champion isn't just charming, he also is very smart.
While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n Γ m multiplication table, where the element on the intersection of the i-th row and j-th column equals iΒ·j (the rows and ... | 24,235 |
Chaneka has a hobby of playing with animal toys. Every toy has a different fun value, a real number. Chaneka has four boxes to store the toys with specification:
* The first box stores toys with fun values in range of (-β,-1].
* The second box stores toys with fun values in range of (-1, 0).
* The third box s... | 24,236 |
You are given an integer sequence of length N, a_1,a_2,...,a_N.
For each 1β€iβ€N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.
After these operations, you select an integer X and count the number of i such that a_i=X.
Maximize this count by making optimal choices.
Constraints
* 1β€Nβ€10^5
*... | 24,237 |
Alice and Bob are fighting over who is a superior debater. However they wish to decide this in a dignified manner.
So they decide to fight in the Battle of Words.
In each game both get to speak a sentence. Because this is a dignified battle, they do not fight physically, the alphabets in their words do so for them. ... | 24,238 |
Polycarpus has got n candies and m friends (n β₯ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's prese... | 24,239 |
In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval I2 from our set if there is a sequence of successive moves starting from I1 so ... | 24,240 |
With the T20 world cup going on, a list of batsmen was prepared with their country code and their T20I career runs.
The list contains data of N batsmen (country-code and runs).
Number of countries may range from 1 to N and each country has its unique code.
The list is pretty unorganized. Virat and Maxwell do not ... | 24,241 |
HackerMan has brought a new drawing book for his child, which consists only of geometric shapes. Its consists of lessons where the child has to make drawings using the geometric shapes. The first lesson is based on how to use squares to build different objects.
You are task is to help HackerMan in teaching one part o... | 24,242 |
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 and decided to make himself k-multihedgehog.
Let us define k-multihedgehog as fol... | 24,243 |
Boboniu defines BN-string as a string s of characters 'B' and 'N'.
You can perform the following operations on the BN-string s:
* Remove a character of s.
* Remove a substring "BN" or "NB" of s.
* Add a character 'B' or 'N' to the end of s.
* Add a string "BN" or "NB" to the end of s.
Note that a strin... | 24,244 |
Polycarp is making a quest for his friends. He has already made n tasks, for each task the boy evaluated how interesting it is as an integer qi, and the time ti in minutes needed to complete the task.
An interesting feature of his quest is: each participant should get the task that is best suited for him, depending o... | 24,245 |
You're given two arrays a[1 ... n] and b[1 ... n], both of the same length n.
In order to perform a push operation, you have to choose three integers l, r, k satisfying 1 β€ l β€ r β€ n and k > 0. Then, you will add k to elements a_l, a_{l+1}, β¦, a_r.
For example, if a = [3, 7, 1, 4, 1, 2] and you choose (l = 3, r = 5, ... | 24,246 |
Background
Mr. A and Mr. B are enthusiastic about the game "Changing Grids". This game is for two players, with player 1 forming the stage and player 2 challenging the stage and aiming for the goal.
Now, A and B have played this game several times, but B has never won because of A's winning streak. So you decided to ... | 24,247 |
Our Code Monk recently learnt about Graphs and is very excited!
He went over to the Graph-making factory to watch some freshly prepared graphs. Incidentally, one of the workers at the factory was ill today, so Monk decided to step in and do her job.
The Monk's Job is to Identify whether the incoming graph is a tr... | 24,248 |
In 1976 the βFour Color Map Theoremβ was proven with the assistance of a computer. This theorem
states that every map can be colored using only four colors, in such a way that no region is colored
using the same color as a neighbor region.
Here you are asked to solve a simpler similar problem. You have to decide wheth... | 24,249 |
Finally Fox Ciel arrived in front of her castle!
She have to type a password to enter her castle. An input device attached to her castle is a bit unusual.
The input device is a 1 Γ n rectangle divided into n square panels. They are numbered 1 to n from left to right. Each panel has a state either ON or OFF. Initially... | 24,250 |
Tokitsukaze is playing a room escape game designed by SkywalkerT. In this game, she needs to find out hidden clues in the room to reveal a way to escape.
After a while, she realizes that the only way to run away is to open the digital door lock since she accidentally went into a secret compartment and found some clues... | 24,251 |
You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...
You are given an array of integers. Sort it in non-descending order.
Input
The input consists of a single line... | 24,252 |
People in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.
Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest wa... | 24,253 |
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 β€ A, B, C β€ 105). Any coefficient may be equal to 0.
Output
In case of infinite root cou... | 24,254 |
View Russian Translation
One day Benny was walking and realized that her life was boring. Everything was grey, even roads in the best park were grey.
Therefore she decided to make roads a little bit brighter. She know that every road in the park is a segment laying on the X axis with coordinates Xl, Xr (Xl β€ Xr). Roa... | 24,255 |
You are on the island which can be represented as a n Γ m table. The rows are numbered from 1 to n and the columns are numbered from 1 to m. There are k treasures on the island, the i-th of them is located at the position (r_i, c_i).
Initially you stand at the lower left corner of the island, at the position (1, 1). I... | 24,256 |
Chef likes rectangles. Among all possible rectangles, he loves rectangles that can be drawn like a grid, such that they have N rows and M columns. Grids are common in Byteland. Hence, Chef has drawn such a rectangle and plans on moving around in it.
The rows of the rectangle are labeled from 1 to N from top to bottom. ... | 24,257 |
An inversion in an array is a pair of indices (i, j) such that A[i] > A[j] and i < j, but you are given two arrays A and B and pairs such that A[i] > B[j] and i < j is called Inversion.
If total number of inversions T, is a prime number then the that will be called a MAGIC INVERSION, otherwise it will be a SIMPLE INV... | 24,258 |
You have a long fence which consists of n sections. Unfortunately, it is not painted, so you decided to hire q painters to paint it. i-th painter will paint all sections x such that l_i β€ x β€ r_i.
Unfortunately, you are on a tight budget, so you may hire only q - 2 painters. Obviously, only painters you hire will do t... | 24,259 |
Imp is really pleased that you helped him. But it you solve the last problem, his gladness would raise even more.
<image> Let's define <image> for some set of integers <image> as the number of pairs a, b in <image>, such that:
* a is strictly less than b;
* a divides b without a remainder.
You are to find su... | 24,260 |
Print all subsets of a set $S$, which contains $0, 1, ... n-1$ as elements. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a subset is calculated by bitwise OR of existing elements.
Constraints
* $1 \leq n \leq 18$
In... | 24,261 |
Johnny has recently found an ancient, broken computer. The machine has only one register, which allows one to put in there one variable. Then in one operation, you can shift its bits left or right by at most three positions. The right shift is forbidden if it cuts off some ones. So, in fact, in one operation, you can m... | 24,262 |
You are given an array a of length n that consists of zeros and ones.
You can perform the following operation multiple times. The operation consists of two steps:
1. Choose three integers 1 β€ x < y < z β€ n, that form an arithmetic progression (y - x = z - y).
2. Flip the values a_x, a_y, a_z (i.e. change 1 to 0... | 24,263 |
Second Problem B War
2D enthusiasts (2D Respecters) from R University will participate in a programming training camp held at Atsu University. In this training camp, participants bring their own programming problems and use them for practice. This year, the 2D Respecters ran for the questioner of question B, who can e... | 24,264 |
Snuke has a rooted tree with N vertices, numbered 1 through N. Vertex 1 is the root of the tree, and the parent of Vertex i ( 2\leq i \leq N ) is Vertex P_i ( P_i < i ). There is a number, 0 or 1, written on each vertex. The number written on Vertex i is V_i.
Snuke would like to arrange the vertices of this tree in a ... | 24,265 |
Qwerty the Ranger arrived to the Diatar system with a very important task. He should deliver a special carcinogen for scientific research to planet Persephone. This is urgent, so Qwerty has to get to the planet as soon as possible. A lost day may fail negotiations as nobody is going to pay for an overdue carcinogen.
Y... | 24,266 |
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
<image>
The combination lock is represented by n rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has t... | 24,267 |
In AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:
* Rating 1-399 : gray
* Rating 400-799 : brown
* Rating 800-1199 : green
* Rating 1200-1599 : cyan
* Rating 1600-1999 : blue
* Rating 2000-2399 : yellow
* Rating 2400-2799 : orange
* Rating 280... | 24,268 |
You came to a brand-new aqua park. In this aqua park you are not sliding like in most of aqua parks, but falling.
There are N objects. Each object is non-horizontal and non-vertical segment. When you fall on the segment you start sliding on it and when you reach its lowest point you continue falling vertically. Then yo... | 24,269 |
A video game company called ICPC (International Company for Playing and Competing) is now developing a new arcade game. The new game features a lot of branches. This makes the game enjoyable for everyone, since players can choose their routes in the game depending on their skills. Rookie players can choose an easy rout... | 24,270 |
Dexterina and Womandark have been arch-rivals since theyβve known each other. Since both are super-intelligent teenage girls, theyβve always been trying to solve their disputes in a peaceful and nonviolent way. After god knows how many different challenges theyβve given to one another, their score is equal and theyβre ... | 24,271 |
In 20XX, many years of research have paid off, and wireless energy transmission and reception technology has been put into practical use. By using this technology, it has become possible to supply power to depopulated areas where it was not possible to draw power lines because the cost was not worth it. This technology... | 24,272 |
Problem statement
2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},β¦, a_ {Nβ1}.
Now, 2D's refrigerator doesn't contain any ingredients, so I have to go to the supermarket to buy it. At the supermarket, you can buy the material a_ {i} for the price x_ {i} yen.
2D ... | 24,273 |
Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.
During an audit, you were surprised to find out that the... | 24,274 |
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 Bitland a sausage is an array of integers! A sausage's deliciousness i... | 24,275 |
Kirti likes 8. Kirti's restaurant has many menus whose prices are multiples of 8. Now, Kirti has some digits written on a wooden board, and she'd like to cut the board to display prices in a new menu. In how many ways can Kirti choose consecutive digits from the board which denote integer multiples of 8?
In this probl... | 24,276 |
Tic-Tac-Toe are three cousins. They are playing a game on Fibonacci numbers. The rule of the game is simple -
If the sum of Non-Fibonacci numbers upto N is prime, Tic wins.
If the sum of Non-Fibonacci numbers upto N is even, Tac wins.
If the sum of Non-Fibonacci numbers upto N is odd and not prime, Toe wins.
Fibonacci... | 24,277 |
Xsquare get bored playing with the arrays all the time. So,he decided to buy a new character set to play with. Xsquare's character set contains only lower case alphabets more specifically characters from 'a' to 'z' (both inclusive). Xsquare was playing with this new character set and formed some interesting continuous ... | 24,278 |
The Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area around Tokyo in Japan. However, each time, five warriors calling themselves the Human Squadron Ear... | 24,279 |
You are given an array a_1, a_2, β¦, a_n.
In one operation you can choose two elements a_i and a_j (i β j) and decrease each of them by one.
You need to check whether it is possible to make all the elements equal to zero or not.
Input
The first line contains a single integer n (2 β€ n β€ 10^5) β the size of the array.... | 24,280 |
Nezzar has n balls, numbered with integers 1, 2, β¦, n. Numbers a_1, a_2, β¦, a_n are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means that a_i β€ a_{i+1} for all 1 β€ i < n.
Nezzar wants to color the balls using the minimum number of colors, such that the following holds.
... | 24,281 |
Polycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.
Simple garlands consisting of several lamps connected by one wire are too boring for Polycarp. He is going to solder a garland consisting of n lam... | 24,282 |
You've got an n Γ n Γ n cube, split into unit cubes. Your task is to number all unit cubes in this cube with positive integers from 1 to n3 so that:
* each number was used as a cube's number exactly once;
* for each 1 β€ i < n3, unit cubes with numbers i and i + 1 were neighbouring (that is, shared a side);
* ... | 24,283 |
Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions:
* He never visits a point with coordinate less than 0, or a point with coordinate greater than L.
* He starts walking at a point with integer coordinate, and also finishes walking at a point with ... | 24,284 |
Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by <image>. A Modular Equation, as Hamed's teacher described, is an equation of the form <image> in which a and b are two non-negative integers a... | 24,285 |
During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.
The collection of porcelain is arranged neatly on n shelves. Within each shelf the items are placed in one row, so that one can access only the outermost items β the leftmost or the r... | 24,286 |
Create a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface distance between two points is the shortest distance along this sphere. Also, in the southern hemis... | 24,287 |
In the evenings Donkey would join Shrek to look at the stars. They would sit on a log, sipping tea and they would watch the starry sky. The sky hung above the roof, right behind the chimney. Shrek's stars were to the right of the chimney and the Donkey's stars were to the left. Most days the Donkey would just count the... | 24,288 |
Saurav has put up Chinese food stall in the college fest. He has arranged everything but he was not able to find chop-sticks in any shop. He decided to make some himself. After hours of efforts, he was able to collect a few ice cream sticks that resembled chop sticks. The problem was that they were not in pair.
Saurav... | 24,289 |
Hexagonal numbers are figurate numbers which can be calculated using the formula hn = 2n2 - n. You are given n; calculate n-th hexagonal number.
Input
The only line of input contains an integer n (1 β€ n β€ 100).
Output
Output the n-th hexagonal number.
Examples
Input
2
Output
6
Input
5
Output
45 | 24,290 |
It's Petya's birthday party and his friends have presented him a brand new "Electrician-n" construction set, which they are sure he will enjoy as he always does with weird puzzles they give him.
Construction set "Electrician-n" consists of 2n - 1 wires and 2n light bulbs. Each bulb has its own unique index that is an ... | 24,291 |
You are given n integers a_1, a_2, ..., a_n, such that for each 1β€ i β€ n holds i-nβ€ a_iβ€ i-1.
Find some nonempty subset of these integers, whose sum is equal to 0. It can be shown that such a subset exists under given constraints. If there are several possible subsets with zero-sum, you can find any of them.
Input
E... | 24,292 |
The only difference between easy and hard versions is the maximum value of n.
You are given a positive integer number n. You really love good numbers so you want to find the smallest good number greater than or equal to n.
The positive integer is called good if it can be represented as a sum of distinct powers of 3 (... | 24,293 |
The evil mastermind, Moriarty, strikes again! He sent Sherlock an image of a wall, with N integers painted on it. Sherlock is asked to solve the puzzle and find the next clue.
Sherlock knows that Moriarty is a deceitful person. All the numbers painted on the wall are not valid. Only the numbers that are Coprime with t... | 24,294 |
As Gerald ..., in other words, on a New Year Eve Constantine prepared an unusual present for the Beautiful Lady. The present is the magic New Year snowflake that can make any dream come true.
The New Year snowflake consists of tiny ice crystals, which can be approximately regarded as points on the plane. The beauty of... | 24,295 |
Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.
Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colo... | 24,296 |
Problem Statement
Kikuchi loves big bicycles. Today he is still riding his favorite bike on the cycling road.
There are N towns in the area where he lives. Each town will be called town 1, town 2 ..., town N. The town where he lives is Town 1. Many people in this area have a hobby of cycling, and recently, cycling ro... | 24,297 |
You are given a convex polygon P with n distinct vertices p1, p2, ..., pn. Vertex pi has coordinates (xi, yi) in the 2D plane. These vertices are listed in clockwise order.
You can choose a real number D and move each vertex of the polygon a distance of at most D from their original positions.
Find the maximum value ... | 24,298 |
This is the hard version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the problem are solved.
There are two binary strings a and b of length n (a binary string is a string consisting of symbols 0 and 1). In ... | 24,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.