question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Apart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Year is considered lucky if it has no more than 1 non-zero digit in its number. So years 100, 40000, 5 are lucky and 12, 3001 and 12345 are not.
Y... |
Solve the programming task below in a Python markdown code block.
The king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensi... |
Solve the programming task below in a Python markdown code block.
In 21XX, an annual programming contest, Japan Algorithmist GrandPrix (JAG) has become one of the most popular mind sports events.
JAG is conducted as a knockout tournament. This year, $N$ contestants will compete in JAG. A tournament chart is represent... |
Solve the programming task below in a Python markdown code block.
The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each pe... |
Solve the programming task below in a Python markdown code block.
problem
JOI decided to play a game with his friends. N players participate in this game. The rules for a single game are as follows:
Each player writes a favorite integer from 1 to 100 on the card and submits it. Each player gets the same score as he ... |
Solve the programming task below in a Python markdown code block.
Once upon a time Petya and Gena gathered after another programming competition and decided to play some game. As they consider most modern games to be boring, they always try to invent their own games. They have only stickers and markers, but that won't... |
Solve the programming task below in a Python markdown code block.
Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.
In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.
Du will chat in the group for $n$ da... |
Solve the programming task below in a Python markdown code block.
In this problem you will meet the simplified model of game King of Thieves.
In a new ZeptoLab game called "King of Thieves" your aim is to reach a chest with gold by controlling your character, avoiding traps and obstacles on your way. [Image]
An int... |
Solve the programming task below in a Python markdown code block.
Your task is to write a program which reads an expression and evaluates it.
* The expression consists of numerical values, operators and parentheses, and the ends with '='.
* The operators includes +, - , *, / where respectively represents, addition, s... |
Solve the programming task below in a Python markdown code block.
Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`.
Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7:
* For each i (1 \leq ... |
Solve the programming task below in a Python markdown code block.
For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?
Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't... |
Solve the programming task below in a Python markdown code block.
Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him crazy. For examp... |
Solve the programming task below in a Python markdown code block.
A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this... |
Solve the programming task below in a Python markdown code block.
A: A-Z-
problem
There is a circular board of 26 squares, each square with one capital letter of the alphabet written clockwise in alphabetical order. That is, the clockwise side of the'A'square is the'B' square, the next side of the'B'square is the'C'... |
Solve the programming task below in a Python markdown code block.
For an array a of integers let's denote its maximal element as max(a), and minimal as min(a). We will call an array a of k integers interesting if max(a) - min(a) β₯ k. For example, array [1, 3, 4, 3] isn't interesting as max(a) - min(a) = 4 - 1 = 3 < 4 ... |
Solve the programming task below in a Python markdown code block.
The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.
Check the king's moves here https://en... |
Solve the programming task below in a Python markdown code block.
The Collatz conjecture is one of the most famous one. Take any positive integer n, if it is even divide it by 2, if it is odd multiply it by 3 and add 1 and continue indefinitely.The conjecture is that whatever is n the sequence will reach 1. There is m... |
Solve the programming task below in a Python markdown code block.
You are given three integers $x, y$ and $n$. Your task is to find the maximum integer $k$ such that $0 \le k \le n$ that $k \bmod x = y$, where $\bmod$ is modulo operation. Many programming languages use percent operator % to implement it.
In other wor... |
Solve the programming task below in a Python markdown code block.
Karlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifically, there were $2n$ jars of strawberry and blueberry jam.
All the $2n$ jars are arranged in a row. The stairs to the basement are exactly in th... |
Solve the programming task below in a Python markdown code block.
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.
Con... |
Solve the programming task below in a Python markdown code block.
Given a credit card number we can determine who the issuer/vendor is with a few basic knowns.
```if:python
Complete the function `get_issuer()` that will use the values shown below to determine the card issuer for a given card number. If the number can... |
Solve the programming task below in a Python markdown code block.
M-kun has the following three cards:
* A red card with the integer A.
* A green card with the integer B.
* A blue card with the integer C.
He is a genius magician who can do the following operation at most K times:
* Choose one of the three cards a... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Russian here
The Head Chef has been playing with Fibonacci numbers for long . He has learnt several tricks related to Fibonacci numbers . Now he wants to test his chefs in the skills .
A fibonacci number is defined by the... |
Solve the programming task below in a Python markdown code block.
We start with a permutation a_1, a_2, β¦, a_n and with an empty array b. We apply the following operation k times.
On the i-th iteration, we select an index t_i (1 β€ t_i β€ n-i+1), remove a_{t_i} from the array, and append one of the numbers a_{t_i-1} or... |
Solve the programming task below in a Python markdown code block.
_Based on [Project Euler problem 35](https://projecteuler.net/problem=35)_
A circular prime is a prime in which every circular permutation of that number is also prime. Circular permutations are created by rotating the digits of the number, for example... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Chef is playing a game. Currently in the game, he is at a field full of stones. There are total N kinds of
stones. There is unlimited supply of each kind of stone.
Chef knows that one ston... |
Solve the programming task below in a Python markdown code block.
In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.
The competition you participate in is to compete for the time it takes to destroy all the blue object... |
Solve the programming task below in a Python markdown code block.
There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may sh... |
Solve the programming task below in a Python markdown code block.
For an array b of length m we define the function f as
f(b) = \begin{cases} b[1] & if m = 1 \\\ f(b[1] β b[2],b[2] β b[3],...,b[m-1] β b[m]) & otherwise, \end{cases}
where β is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitwise_oper... |
Solve the programming task below in a Python markdown code block.
There is a deck of $n$ cards. The $i$-th card has a number $a_i$ on the front and a number $b_i$ on the back. Every integer between $1$ and $2n$ appears exactly once on the cards.
A deck is called sorted if the front values are in increasing order and ... |
Solve the programming task below in a Python markdown code block.
###Instructions
Write a function that takes a negative or positive integer, which represents the number of minutes before (-) or after (+) Sunday midnight, and returns the current day of the week and the current time in 24hr format ('hh:mm') as a strin... |
Solve the programming task below in a Python markdown code block.
Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.
Two cards can form a pair if the absolute value of the difference of the integers written on them is at most ... |
Solve the programming task below in a Python markdown code block.
There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.
First, Snuke will arrange the N balls in a row from left to right.
Then, Takahashi will collect only the K b... |
Solve the programming task below in a Python markdown code block.
A function $f : R \rightarrow R$ is called Lipschitz continuous if there is a real constant K such that the inequality |f(x) - f(y)| β€ KΒ·|x - y| holds for all $x, y \in R$. We'll deal with a more... discrete version of this term.
For an array $h [ 1 . ... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian as well.
You had an array of integer numbers. You also had a beautiful operations called "Copy-Paste" which allowed you to copy any contiguous subsequence of your array and paste it in any posit... |
Solve the programming task below in a Python markdown code block.
A median of an array of integers of length $n$ is the number standing on the $\lceil {\frac{n}{2}} \rceil$ (rounding up) position in the non-decreasing ordering of its elements. Positions are numbered starting with $1$. For example, a median of the arra... |
Solve the programming task below in a Python markdown code block.
A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels.
Your task is to determine the size of the rectangular display β the number of lines (rows) of pixels a and the number of col... |
Solve the programming task below in a Python markdown code block.
You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 β€ l β€ r β€ n. Indices in array are numbered fr... |
Solve the programming task below in a Python markdown code block.
Valera has got n domino pieces in a row. Each piece consists of two halves β the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the numbers on the upper halves ... |
Solve the programming task below in a Python markdown code block.
You are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of ... |
Solve the programming task below in a Python markdown code block.
We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possib... |
Solve the programming task below in a Python markdown code block.
Given an array of $n$ positive integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 1000$). Find the maximum value of $i + j$ such that $a_i$ and $a_j$ are coprime,$^{\dagger}$ or $-1$ if no such $i$, $j$ exist.
For example consider the array $[1, 3, 5, 2, ... |
Solve the programming task below in a Python markdown code block.
# Scenario
*You're saying good-bye your best friend* , **_See you next happy year_** .
**_Happy Year_** *is the year with only distinct digits* , (e.g) **_2018_**
___
# Task
**_Given_** a year, **_Find_** **_The next happy year_** or **_The closes... |
Solve the programming task below in a Python markdown code block.
We have a grid with N rows and M columns of squares. Initially, all the squares are white.
There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that ... |
Solve the programming task below in a Python markdown code block.
You are given n points on a plane. All points are different.
Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC.
The groups of three points are considered unordered, that is, if point B is the ... |
Solve the programming task below in a Python markdown code block.
# Task
Mobius function - an important function in number theory. For each given n, it only has 3 values:
```
0 -- if n divisible by square of a prime. Such as: 4, 8, 9
1 -- if n not divisible by any square of a prime
and have even number of ... |
Solve the programming task below in a Python markdown code block.
<image>
You know the merry-go-round in the amusement park. Vehicles such as horses and carriages are fixed on a large disk, and it is a standard playset that the vehicle swings up and down at the same time as the disk rotates. A merry-go-round in an a... |
Solve the programming task below in a Python markdown code block.
You are given positive integer number n. You should create such strictly increasing sequence of k positive numbers a_1, a_2, ..., a_{k}, that their sum is equal to n and greatest common divisor is maximal.
Greatest common divisor of sequence is maximum... |
Solve the programming task below in a Python markdown code block.
Problem
There are $ N $ streetlights on a two-dimensional square of $ W \ times H $.
Gaccho wants to start with $ (1,1) $ and go to $ (W, H) $.
Gaccho is afraid of dark places, so he only wants to walk in the squares that are brightened by the streetli... |
Solve the programming task below in a Python markdown code block.
We have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as follows:
* First, write 0 in every square.
* For each i=1,2,...,N, choose an integer k_i (0\leq k_i\leq M), and add 1 to each of the leftmost k_... |
Solve the programming task below in a Python markdown code block.
The sequence of integers $a_1, a_2, \dots, a_k$ is called a good array if $a_1 = k - 1$ and $a_1 > 0$. For example, the sequences $[3, -1, 44, 0], [1, -99]$ are good arrays, and the sequences $[3, 7, 8], [2, 5, 4, 1], [0]$ β are not.
A sequence of inte... |
Solve the programming task below in a Python markdown code block.
Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.
A tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in such... |
Solve the programming task below in a Python markdown code block.
A: A-Z Cat / A-Z Cat
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend Joy to take care of her cat. It is ... |
Solve the programming task below in a Python markdown code block.
Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk.
Empirically Polycarp learned that the dog needs at least k walks for any two consecutive days in order to... |
Solve the programming task below in a Python markdown code block.
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.
Only Japanese students or overseas students can pass the Qualification contests. The ... |
Solve the programming task below in a Python markdown code block.
Let's call a positive integer $n$ ordinary if in the decimal notation all its digits are the same. For example, $1$, $2$ and $99$ are ordinary numbers, but $719$ and $2021$ are not ordinary numbers.
For a given number $n$, find the number of ordinary n... |
Solve the programming task below in a Python markdown code block.
Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:
* Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the sco... |
Solve the programming task below in a Python markdown code block.
Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U a... |
Solve the programming task below in a Python markdown code block.
Consider the set of all nonnegative integers: ${0, 1, 2, \dots}$. Given two integers $a$ and $b$ ($1 \le a, b \le 10^4$). We paint all the numbers in increasing number first we paint $0$, then we paint $1$, then $2$ and so on.
Each number is painted wh... |
Solve the programming task below in a Python markdown code block.
I love Fibonacci numbers in general, but I must admit I love some more than others.
I would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence.
For example:
```python
nth_fib(4) == ... |
Solve the programming task below in a Python markdown code block.
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.
The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you h... |
Solve the programming task below in a Python markdown code block.
problem
Given the squares of $ R * C $. Each square is either an empty square or a square with a hole. The given square meets the following conditions.
* The cells with holes are connected. (You can move a square with a hole in the cross direction to ... |
Solve the programming task below in a Python markdown code block.
There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c_1, c_2, ..., c_{n}. The Old Peykan wants to travel from city c_1 to c_{n} using roads. There are (n - 1)... |
Solve the programming task below in a Python markdown code block.
# Task
You are a lifelong fan of your local football club, and proud to say you rarely miss a game. Even though you're a superfan, you still hate boring games. Luckily, boring games often end in a draw, at which point the winner is determined by a penal... |
Solve the programming task below in a Python markdown code block.
There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for... |
Solve the programming task below in a Python markdown code block.
Niwango has N cards, numbered 1,2,\ldots,N. He will now arrange these cards in a row.
Niwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the ans... |
Solve the programming task below in a Python markdown code block.
Given are two sequences a=\{a_0,\ldots,a_{N-1}\} and b=\{b_0,\ldots,b_{N-1}\} of N non-negative integers each.
Snuke will choose an integer k such that 0 \leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\{a_0',\ldots,a... |
Solve the programming task below in a Python markdown code block.
Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).
You are given an integer $n$. You need to find two integers $l$ and $r$ such that $-10^{18} \le l < r \le 10^{18}$ and $l... |
Solve the programming task below in a Python markdown code block.
Example
Input
4
Durett 7
Gayles 3
Facenda 6
Daughtery 0
1
+ Mccourtney 2
Output
Mccourtney is not working now.
Durett is working hard now.
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sam... |
Solve the programming task below in a Python markdown code block.
Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Pet... |
Solve the programming task below in a Python markdown code block.
Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.
It is an undirected weighted graph on... |
Solve the programming task below in a Python markdown code block.
Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In other w... |
Solve the programming task below in a Python markdown code block.
You are given two arrays $a$ and $b$, both of length $n$.
You can perform the following operation any number of times (possibly zero): select an index $i$ ($1 \leq i \leq n$) and swap $a_i$ and $b_i$.
Let's define the cost of the array $a$ as $\sum_{i... |
Solve the programming task below in a Python markdown code block.
BerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly n / 2 lines of strictly equal l... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions are constraints on $n$ and $k$.
You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially,... |
Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.
A bar of chocolate can be presented as an n Γ n table, where each cell represents one piece of chocolate. The columns of the ... |
Solve the programming task below in a Python markdown code block.
An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, ... |
Solve the programming task below in a Python markdown code block.
Vasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be represented by a single word contain... |
Solve the programming task below in a Python markdown code block.
There are N squares arranged in a row, numbered 1 to N from left to right. Takahashi will stack building blocks on these squares, on which there are no blocks yet.
He wants to stack blocks on the squares evenly, so he will repeat the following operatio... |
Solve the programming task below in a Python markdown code block.
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.
Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.
You are given a string s consisting of upperc... |
Solve the programming task below in a Python markdown code block.
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, such th... |
Solve the programming task below in a Python markdown code block.
Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She ... |
Solve the programming task below in a Python markdown code block.
Example
Input
3
0 2 7
2 0 4
5 8 0
Output
11
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters. |
Solve the programming task below in a Python markdown code block.
You are given a string S of length 2N consisting of lowercase English letters.
There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?
* The string obtained by reading the characters ... |
Solve the programming task below in a Python markdown code block.
Today's Random Number
E869120 You ran a campaign called "Today's Random Numbers" for N days. This is a project to generate a random number once a day and post the value on Twitter.
The "random numbers of the day" on day $ 1, 2, 3, \ dots, N $ were $ A... |
Solve the programming task below in a Python markdown code block.
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is the ... |
Solve the programming task below in a Python markdown code block.
Turbulent times are coming, so you decided to buy sugar in advance. There are $n$ shops around that sell sugar: the $i$-th shop sells one pack of sugar for $a_i$ coins, but only one pack to one customer each day. So in order to buy several packs, you ne... |
Solve the programming task below in a Python markdown code block.
You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the syst... |
Solve the programming task below in a Python markdown code block.
Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through $n \cdot k$ cities. The cities are numerated from $1$ to $n \cdot k$, the distance between the neighboring cities is exactly $1$ km.
Sergey does not like b... |
Solve the programming task below in a Python markdown code block.
Sereja has an n Γ m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of ... |
Solve the programming task below in a Python markdown code block.
You are given an array a consisting of n integers. We denote the subarray a[l..r] as the array [a_l, a_{l + 1}, ..., a_r] (1 β€ l β€ r β€ n).
A subarray is considered good if every integer that occurs in this subarray occurs there exactly thrice. For exam... |
Solve the programming task below in a Python markdown code block.
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.
* Initia... |
Solve the programming task below in a Python markdown code block.
Given two numbers (m and n) :
- convert all numbers from m to n to binary
- sum them as if they were in base 10
- convert the result to binary
- return as string
Eg: with the numbers 1 and 4
1 // 1 to binary is 1
+ 10 // 2 to binary is 10
+ 11 /... |
Solve the programming task below in a Python markdown code block.
On Bertown's main street n trees are growing, the tree number i has the height of ai meters (1 β€ i β€ n). By the arrival of the President of Berland these trees were decided to be changed so that their heights formed a beautiful sequence. This means that... |
Solve the programming task below in a Python markdown code block.
We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i.
There is one cursor. The cursor's location β is denoted by an integer in \{0, β¦,... |
Solve the programming task below in a Python markdown code block.
In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n Γ m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the ... |
Solve the programming task below in a Python markdown code block.
# Task
Define crossover operation over two equal-length strings A and B as follows:
the result of that operation is a string of the same length as the input strings result[i] is chosen at random between A[i] and B[i].
Given array of strings `arr`... |
Solve the programming task below in a Python markdown code block.
For an integer n not less than 0, let us define f(n) as follows:
- f(n) = 1 (if n < 2)
- f(n) = n f(n-2) (if n \geq 2)
Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
-----Constraints-----
- 0 \leq N \leq 10... |
Solve the programming task below in a Python markdown code block.
Matrix of given integers
a1,1 a1,2 ... a1, n
a2,1 a2,2 ... a2, n
::
an, 1 an, 2 ... an, n
Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and end... |
Solve the programming task below in a Python markdown code block.
One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.
A bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.