question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
In the Jambo Amusement Garden (JAG), you sell colorful drinks consisting of multiple color layers. This colorful drink can be made by pouring multiple colored liquids of different density from the bottom in order.
You have already prepared several colo... |
Solve the programming task below in a Python markdown code block.
Quantum mechanics tells us that a molecule is only allowed to have specific, discrete amounts of internal energy. The 'rigid rotor model', a model for describing rotations, tells us that the amount of rotational energy a molecule can have is given by: ... |
Solve the programming task below in a Python markdown code block.
There are N squares numbered 1 to N from left to right. Each square has a character written on it, and Square i has a letter s_i. Besides, there is initially one golem on each square.
Snuke cast Q spells to move the golems.
The i-th spell consisted of... |
Solve the programming task below in a Python markdown code block.
Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number b_{i}. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. S... |
Solve the programming task below in a Python markdown code block.
As Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That is, the direct link between clues A and B an... |
Solve the programming task below in a Python markdown code block.
You are given the current time in 24-hour format hh:mm. Find and print the time after a minutes.
Note that you should find only the time after a minutes, see the examples to clarify the problem statement.
You can read more about 24-hour format here ht... |
Solve the programming task below in a Python markdown code block.
Nickname Generator
Write a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as a nickname.
If the 3rd letter is a consonant, return the first 3 letters.
If the 3rd letter is a vowel, return th... |
Solve the programming task below in a Python markdown code block.
Problem statement
There is a positive integer sequence $ a_1, a_2, \ ldots, a_N $ of length $ N $.
Consider the following game, which uses this sequence and is played by $ 2 $ players on the play and the play.
* Alternately select one of the followin... |
Solve the programming task below in a Python markdown code block.
Given a positive integer $k$, two arrays are called $k$-similar if:
they are strictly increasing;
they have the same length;
all their elements are positive integers between $1$ and $k$ (inclusive);
they differ in exactly one position.
You are give... |
Solve the programming task below in a Python markdown code block.
Stepan has a very big positive integer.
Let's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading zeros). Let's call such shifts as good shifts. For example,... |
Solve the programming task below in a Python markdown code block.
Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j). Mike's hands ar... |
Solve the programming task below in a Python markdown code block.
Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted... |
Solve the programming task below in a Python markdown code block.
Takahashi has K 500-yen coins. (Yen is the currency of Japan.)
If these coins add up to X yen or more, print Yes; otherwise, print No.
-----Constraints-----
- 1 \leq K \leq 100
- 1 \leq X \leq 10^5
-----Input-----
Input is given from Standard Input ... |
Solve the programming task below in a Python markdown code block.
Pupils Alice and Ibragim are best friends. It's Ibragim's birthday soon, so Alice decided to gift him a new puzzle. The puzzle can be represented as a matrix with $2$ rows and $n$ columns, every element of which is either $0$ or $1$. In one move you can... |
Solve the programming task below in a Python markdown code block.
Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (in decimal representation) is no... |
Solve the programming task below in a Python markdown code block.
Integral numbers can be even or odd.
Even numbers satisfy `n = 2m` ( with `m` also integral ) and we will ( completely arbitrarily ) think of odd numbers as `n = 2m + 1`.
Now, some odd numbers can be more odd than others: when for some `n`, `m` is mo... |
Solve the programming task below in a Python markdown code block.
Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.
In this game, the phone's screen is divided into four vertical strips. Each second, a b... |
Solve the programming task below in a Python markdown code block.
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of sum of digits of the nu... |
Solve the programming task below in a Python markdown code block.
This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1 resp... |
Solve the programming task below in a Python markdown code block.
# Task
John is a programmer. He treasures his time very much. He lives on the `n` floor of a building. Every morning he will go downstairs as quickly as possible to begin his great work today.
There are two ways he goes downstairs: walking or taking t... |
Solve the programming task below in a Python markdown code block.
Ania has a large integer $S$. Its decimal representation has length $n$ and doesn't contain any leading zeroes. Ania is allowed to change at most $k$ digits of $S$. She wants to do it in such a way that $S$ still won't contain any leading zeroes and it'... |
Solve the programming task below in a Python markdown code block.
The Robot is in a rectangular maze of size n × m. Each cell of the maze is either empty or occupied by an obstacle. The Robot can move between neighboring cells on the side left (the symbol "L"), right (the symbol "R"), up (the symbol "U") or down (the ... |
Solve the programming task below in a Python markdown code block.
Difference of Big Integers
Given two integers $A$ and $B$, compute the difference, $A - B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the difference in a line.
Constraints
* $-1 \times 10^{100... |
Solve the programming task below in a Python markdown code block.
The weight of a sequence is defined as the number of unordered pairs of indexes $(i,j)$ (here $i \lt j$) with same value ($a_{i} = a_{j}$). For example, the weight of sequence $a = [1, 1, 2, 2, 1]$ is $4$. The set of unordered pairs of indexes with same... |
Solve the programming task below in a Python markdown code block.
For a permutation P[1... N] of integers from 1 to N, function f is defined as follows:
$f(i, j) = \left\{\begin{array}{ll}{P [ i ]} & {\text{if} j = 1} \\{f(P [ i ], j - 1)} & {\text{otherwise}} \end{array} \right.$
Let g(i) be the minimum positive ... |
Solve the programming task below in a Python markdown code block.
You'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it.
examples:
uniTotal("a") == 97
uniTotal("aaa") == 291
Read the inputs from stdin solve the problem and... |
Solve the programming task below in a Python markdown code block.
Given three numbers $n, a, b$. You need to find an adjacency matrix of such an undirected graph that the number of components in it is equal to $a$, and the number of components in its complement is $b$. The matrix must be symmetric, and all digits on t... |
Solve the programming task below in a Python markdown code block.
##Task:
You have to write a function **pattern** which creates the following pattern upto n number of rows.
* If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string.
* If any odd number is passed as argument then the p... |
Solve the programming task below in a Python markdown code block.
One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is $r$ units.
Some very rich customers ... |
Solve the programming task below in a Python markdown code block.
[3R2 as DJ Mashiro - Happiness Breeze](https://open.spotify.com/track/2qGqK8GRS65Wlf20qUBEak)
[Ice - DJ Mashiro is dead or alive](https://soundcloud.com/iceloki/dj-mashiro-is-dead-or-alive)
NEKO#ΦωΦ has just got a new maze game on her PC!
The game's ... |
Solve the programming task below in a Python markdown code block.
Complete the function that takes 3 numbers `x, y and k` (where `x ≤ y`), and returns the number of integers within the range `[x..y]` (both ends included) that are divisible by `k`.
More scientifically: `{ i : x ≤ i ≤ y, i mod k = 0 }`
## Example
G... |
Solve the programming task below in a Python markdown code block.
Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture.
Consider the room floor paved with square tiles whose size fits the cleaning robot (1 × 1). There are 'clean tiles' and 'dirty tiles', and the rob... |
Solve the programming task below in a Python markdown code block.
A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that ... |
Solve the programming task below in a Python markdown code block.
An array $a$ is good if for all pairs of adjacent elements, $a_i$ and $a_{i+1}$ ($1\le i \lt n$) are of different parity. Note that an array of size $1$ is trivially good.
You are given an array of size $n$.
In one operation you can select any pair of... |
Solve the programming task below in a Python markdown code block.
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. [Image]
Initially, each hole has $a_i$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the ... |
Solve the programming task below in a Python markdown code block.
We have N weights indexed 1 to N. The mass of the weight indexed i is W_i.
We will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \leq T < N. Let S_1 be the su... |
Solve the programming task below in a Python markdown code block.
Roman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string multiplication. According to Denis,... |
Solve the programming task below in a Python markdown code block.
Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles.
The hall also turned ... |
Solve the programming task below in a Python markdown code block.
Phoenix is picking berries in his backyard. There are $n$ shrubs, and each shrub has $a_i$ red berries and $b_i$ blue berries.
Each basket can contain $k$ berries. But, Phoenix has decided that each basket may only contain berries from the same shrub o... |
Solve the programming task below in a Python markdown code block.
The BFS algorithm is defined as follows. Consider an undirected graph with vertices numbered from $1$ to $n$. Initialize $q$ as a new queue containing only vertex $1$, mark the vertex $1$ as used. Extract a vertex $v$ from the head of the queue $q$. ... |
Solve the programming task below in a Python markdown code block.
We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.
Initially, the hand of every clock stands still, pointing directly upward.
Now, Dolphin starts all the clocks simultaneously.
In how many seconds will t... |
Solve the programming task below in a Python markdown code block.
$n$ people gathered to hold a jury meeting of the upcoming competition, the $i$-th member of the jury came up with $a_i$ tasks, which they want to share with each other.
First, the jury decides on the order which they will follow while describing the t... |
Solve the programming task below in a Python markdown code block.
Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that
GCD of all integers in that subarray is 1.
Formally,
For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1. You hav... |
Solve the programming task below in a Python markdown code block.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r south-to-north... |
Solve the programming task below in a Python markdown code block.
We have N sticks with negligible thickness.
The length of the i-th stick is A_i.
Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of th... |
Solve the programming task below in a Python markdown code block.
Consider the following series:
`1, 2, 4, 8, 16, 22, 26, 38, 62, 74, 102, 104, 108, 116, 122`
It is generated as follows:
* For single digit integers, add the number to itself to get the next element.
* For other integers, multiply all the non-zero di... |
Solve the programming task below in a Python markdown code block.
Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».
This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and wh... |
Solve the programming task below in a Python markdown code block.
Goldbach's conjecture is one of the oldest and best-known unsolved problems in number theory and all of mathematics. It states:
Every even integer greater than 2 can be expressed as the sum of two primes.
For example:
`6 = 3 + 3`
`8 = 3 + 5`
`10 = 3 ... |
Solve the programming task below in a Python markdown code block.
Write a program which finds a pattern $p$ in a ring shaped text $s$.
<image>
Constraints
* $1 \leq $ length of $p \leq $ length of $s \leq 100$
* $s$ and $p$ consists of lower-case letters
Input
In the first line, the text $s$ is given.
In the sec... |
Solve the programming task below in a Python markdown code block.
Let $f(i)$ denote the minimum positive integer $x$ such that $x$ is not a divisor of $i$.
Compute $\sum_{i=1}^n f(i)$ modulo $10^9+7$. In other words, compute $f(1)+f(2)+\dots+f(n)$ modulo $10^9+7$.
-----Input-----
The first line contains a single i... |
Solve the programming task below in a Python markdown code block.
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "... |
Solve the programming task below in a Python markdown code block.
The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more tha... |
Solve the programming task below in a Python markdown code block.
Notes
Template in C
Constraints
2 ≤ the number of operands in the expression ≤ 100
1 ≤ the number of operators in the expression ≤ 99
-1 × 109 ≤ values in the stack ≤ 109
Input
An expression is given in a line. Two consequtive symbols (operand or o... |
Solve the programming task below in a Python markdown code block.
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on its place, or on the place of anot... |
Solve the programming task below in a Python markdown code block.
Petya works as a PR manager for a successful Berland company BerSoft. He needs to prepare a presentation on the company income growth since 2001 (the year of its founding) till now. Petya knows that in 2001 the company income amounted to a1 billion bour... |
Solve the programming task below in a Python markdown code block.
Problem Statement
Mr. Takatsuki, who is planning to participate in the Aizu training camp, is enthusiastic about studying and has been studying English recently. She tries to learn as many English words as possible by playing the following games on her... |
Solve the programming task below in a Python markdown code block.
You have a robot that can move along a number line. At time moment $0$ it stands at point $0$.
You give $n$ commands to the robot: at time $t_i$ seconds you command the robot to go to point $x_i$. Whenever the robot receives a command, it starts moving... |
Solve the programming task below in a Python markdown code block.
Misha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It is extremely expensive to host ... |
Solve the programming task below in a Python markdown code block.
You are given a sequence $a=[a_1,a_2,\dots,a_n]$ consisting of $n$ positive integers.
Let's call a group of consecutive elements a segment. Each segment is characterized by two indices: the index of its left end and the index of its right end. Denote b... |
Solve the programming task below in a Python markdown code block.
Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether ... |
Solve the programming task below in a Python markdown code block.
There are five people playing a game called "Generosity". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one... |
Solve the programming task below in a Python markdown code block.
Several months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that he has no ready creations, and decided to write a... |
Solve the programming task below in a Python markdown code block.
Your task is to construct a building which will be a pile of n cubes.
The cube at the bottom will have a volume of n^3, the cube above
will have volume of (n-1)^3 and so on until the top which will have a volume of 1^3.
You are given the total volume... |
Solve the programming task below in a Python markdown code block.
1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows:
- the dogs numbered 1,2,\cdots,26 were respectively... |
Solve the programming task below in a Python markdown code block.
Move every letter in the provided string forward 10 letters through the alphabet.
If it goes past 'z', start again at 'a'.
Input will be a string with length > 0.
Read the inputs from stdin solve the problem and write the answer to stdout (do not dir... |
Solve the programming task below in a Python markdown code block.
Little Bolek has found a picture with n mountain peaks painted on it. The n painted peaks are represented by a non-closed polyline, consisting of 2n segments. The segments go through 2n + 1 points with coordinates (1, y1), (2, y2), ..., (2n + 1, y2n + 1... |
Solve the programming task below in a Python markdown code block.
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whet... |
Solve the programming task below in a Python markdown code block.
In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flower 1, 2, …, N. Also, we will cal... |
Solve the programming task below in a Python markdown code block.
The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of n lines defined by the equations y = k_{i}·x + b_{i}. It was necessary to determine w... |
Solve the programming task below in a Python markdown code block.
C --Misawa's rooted tree
Problem Statement
You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1)
* Each vertex ... |
Solve the programming task below in a Python markdown code block.
The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given sing... |
Solve the programming task below in a Python markdown code block.
The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following n days. According to the bear's data, on the i-th (1 ≤ i ≤ n) day, the price for one barrel o... |
Solve the programming task below in a Python markdown code block.
In this kata you will have to modify a sentence so it meets the following rules:
convert every word backwards that is:
longer than 6 characters
OR
has 2 or more 'T' or 't' in it
convert every word uppercase that is:
exactly 2 charact... |
Solve the programming task below in a Python markdown code block.
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a r × c grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only two re... |
Solve the programming task below in a Python markdown code block.
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is a_{i} liters. [Image]
Initially, ... |
Solve the programming task below in a Python markdown code block.
The number 105 is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
-----Constraints-----
- N is an integer between 1 and... |
Solve the programming task below in a Python markdown code block.
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely ... |
Solve the programming task below in a Python markdown code block.
You are given an array $a_1, a_2, \dots , a_n$ consisting of integers from $0$ to $9$. A subarray $a_l, a_{l+1}, a_{l+2}, \dots , a_{r-1}, a_r$ is good if the sum of elements of this subarray is equal to the length of this subarray ($\sum\limits_{i=l}^{... |
Solve the programming task below in a Python markdown code block.
You will be given a contest schedule for D days. For each d=1,2,\ldots,D, calculate the satisfaction at the end of day d.
Input
Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.
D
c_1 c_2... |
Solve the programming task below in a Python markdown code block.
Chef has decided to arrange the free shuttle service for his employees. City of Bhiwani has a strange layout - all of its N shuttle boarding points are arranged in a circle, numbered from 1 to N in clockwise direction. Chef's restaurant is at boarding p... |
Solve the programming task below in a Python markdown code block.
Let's call the string beautiful if it does not contain a substring of length at least $2$, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the last character to the first.... |
Solve the programming task below in a Python markdown code block.
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$.
There are three values about each exam: $s_i$ — ... |
Solve the programming task below in a Python markdown code block.
The only difference between the easy and hard versions are the locations you can teleport to.
Consider the points $0,1,\dots,n+1$ on the number line. There is a teleporter located on each of the points $1,2,\dots,n$. At point $i$, you can do the follow... |
Solve the programming task below in a Python markdown code block.
Since I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer L, how many pairs of positive integers a, b (a ≤ b) such that LCM(a, b) = L are there? Here, LCM(a, b) stands for the least co... |
Solve the programming task below in a Python markdown code block.
Min Element
Given the sequence a_1, a_2, .., a_N.
Find the minimum number in this sequence.
If the minimum value is in more than one place, answer the one with the lowest number.
input
N
a_1 a_2 ... a_N
output
Output the smallest i such that a_... |
Solve the programming task below in a Python markdown code block.
Soon after the Chunga-Changa island was discovered, it started to acquire some forms of civilization and even market economy. A new currency arose, colloquially called "chizhik". One has to pay in chizhiks to buy a coconut now.
Sasha and Masha are abou... |
Solve the programming task below in a Python markdown code block.
Implement function which will return sum of roots of a quadratic equation rounded to 2 decimal places, if there are any possible roots, else return **None/null/nil/nothing**. If you use discriminant,when discriminant = 0, x1 = x2 = root => return sum of... |
Solve the programming task below in a Python markdown code block.
Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In other ... |
Solve the programming task below in a Python markdown code block.
You are given a sequence of a journey in London, UK. The sequence will contain bus **numbers** and TFL tube names as **strings** e.g.
```python
['Northern', 'Central', 243, 1, 'Victoria']
```
Journeys will always only contain a combination of tube name... |
Solve the programming task below in a Python markdown code block.
In the advanced algorithm class, n2 students sit in n rows and n columns. One day, a professor who teaches this subject comes into the class, asks the shortest student in each row to lift up his left hand, and the tallest student in each column to lift ... |
Solve the programming task below in a Python markdown code block.
You are given $n$ positive integers $a_1, \ldots, a_n$, and an integer $k \geq 2$. Count the number of pairs $i, j$ such that $1 \leq i < j \leq n$, and there exists an integer $x$ such that $a_i \cdot a_j = x^k$.
-----Input-----
The first line conta... |
Solve the programming task below in a Python markdown code block.
You are given a regular polygon with $n$ vertices labeled from $1$ to $n$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pair ... |
Solve the programming task below in a Python markdown code block.
A binary string is a string that consists of characters $0$ and $1$. A bi-table is a table that has exactly two rows of equal length, each being a binary string.
Let $\operatorname{MEX}$ of a bi-table be the smallest digit among $0$, $1$, or $2$ that d... |
Solve the programming task below in a Python markdown code block.
You're in ancient Greece and giving Philoctetes a hand in preparing a training exercise for Hercules! You've filled a pit with two different ferocious mythical creatures for Hercules to battle!
The formidable **"Orthus"** is a 2 headed dog with 1 tail.... |
Solve the programming task below in a Python markdown code block.
A tutorial for this problem is now available on our blog. Click here to read it.
You are asked to calculate factorials of some small positive integers.
------ Input ------
An integer t, 1≤t≤100, denoting the number of testcases, followed by t line... |
Solve the programming task below in a Python markdown code block.
There are N people, conveniently numbered 1 through N.
We want to divide them into some number of groups, under the following two conditions:
- Every group contains between A and B people, inclusive.
- Let F_i be the number of the groups containing ex... |
Solve the programming task below in a Python markdown code block.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to sit in class, so the teacher came up with a task for him: ... |
Solve the programming task below in a Python markdown code block.
Your task is very simple. Just write a function `isAlphabetic(s)`, which takes an input string `s` in lowercase and returns `true`/`false` depending on whether the string is in alphabetical order or not.
For example, `isAlphabetic('kata')` is False as ... |
Solve the programming task below in a Python markdown code block.
You wrote down all integers from $0$ to $10^n - 1$, padding them with leading zeroes so their lengths are exactly $n$. For example, if $n = 3$ then you wrote out 000, 001, ..., 998, 999.
A block in an integer $x$ is a consecutive segment of equal digit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.