id
stringlengths
10
13
content
stringlengths
424
1.17M
app_data_2700
Chef likes inequalities. Please help him to solve next one. Given four integers a, b, c, d. Find number of solutions x < y, where a ≤ x ≤ b and c ≤ y ≤ d and x, y integers. -----Input----- The first line contains an integer T denoting number of tests. First line of each test case contains four positive integer numbers...
app_data_2701
In Chef's house there are N apples lying in a row on the floor. These apples are numbered from 1 (left most one) to N (right most one). The types of apples are also numbered by positive integers, and the type of apple i is Ti. Chef has recently brought two trained dogs. Both of the dogs are too intelligent to know the ...
app_data_2702
There has been yet another murder in the Shady city of Riverdale. This murder is being investigated by none other than the Riverdale's Finest- Jughead Jones & Betty Cooper. This murder has been done exactly in the same manner as all the murders happening since the return of the deadly game Gargoyle &Griffins. Betty has...
app_data_2703
Binod and his family live in Codingland. They have a festival called N-Halloween. The festival is celebrated for N consecutive days. On each day Binod gets some candies from his mother. He may or may not take them. On a given day , Binod will be sad if he collected candies on that day and he does not have at least X ...
app_data_2704
Devu has an array A consisting of N positive integers. He would like to perform following operation on array. - Pick some two elements a, b in the array (a could be same as b, but their corresponding indices in the array should not be same). Remove both the elements a and b and instead add a number x such that x lies ...
app_data_2705
Uppal-balu is busy in extraction of gold from ores. He got an assignment from his favorite professor MH sir, but he got stuck in a problem. Can you help Uppal-balu to solve the problem. You are given an array $a_1$, $a_2$, $\dots$, $a_n$ of length $n$. You can perform the following operations on it: - Choose an index $...
app_data_2706
Jack and Jill got into a serious fight. Jack didn't not belive Jill when she said that her memory was far better than the others. He asked her to prove it as follows :- - Jack would dictate a long list of numbers to her. At any point after he has dictated at least "k" numbers, he can ask her what is the k-th minimu...
app_data_2707
Given an array A of n non-negative integers. Find the number of ways to partition/divide the array into subarrays, such that mex in each subarray is not more than k. For example, mex of the arrays [1, 2] will be 0, and that of [0, 2] will be 1, and that of [0, 1, 2] will be 3. Due to the fact that the answer can turn ...
app_data_2708
Ayush is learning how to decrease a number by one, but he does it wrong with a number consisting of two or more digits. Ayush subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, he decreases the number by one. if the last digit of the number is zero, he divides the numbe...
app_data_2709
You think you can code? This problem will test you on various basic programming techniques. You are given two integers $N$ and $t$; and then an array $A$ of $N$ integers ($0$-based indexing). Based on the value of $t$, you will perform an action on $A$. $t$ Action Needed $1$ Print $7$, regardless of the conte...
app_data_2710
In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of a_{i} soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one of neighboring cities by at moving along at most one road. Check if is it p...
app_data_2711
While exploring the old caves, researchers found a book, or more precisely, a stash of mixed pages from a book. Luckily, all of the original pages are present and each page contains its number. Therefore, the researchers can reconstruct the book. After taking a deeper look into the contents of these pages, linguists t...
app_data_2712
Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $a$, $b$, and $c$. Now he needs to find out some possible integer length $d$ of the fourth straight fence segment so that he can build the fence using th...
app_data_2713
The gaming company Sandstorm is developing an online two player game. You have been asked to implement the ranking system. All players have a rank determining their playing strength which gets updated after every game played. There are $25$ regular ranks, and an extra rank, “Legend”, above that. The ranks are numbered ...
app_data_2714
You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges. You have to write a number on each vertex of the graph. Each number should be $1$, $2$ or $3$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd. Calculate the number of possi...
app_data_2715
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. - Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element...
app_data_2716
You think you can code? This problem will test you on various basic programming techniques. You are given two integers $N$ and $t$; and then an array $A$ of $N$ integers ($0$-based indexing). Based on the value of $t$, you will perform an action on $A$. $t$ Action Needed $1$ Print “Yes” if there are two integ...
app_data_2717
It is finally Bobby’s birthday, and all of his Acquaintances, Buddies and Colleagues have gathered for a board game night. They are going to play a board game which is played in up to three big teams. Bobby decided to split his guests into groups based on how well he knows them: the Acquaintances on team $A$, the Buddi...
app_data_2718
You are attending the International Construction by Preschoolers Contest. Unfortunately, you are too old to participate, but you still enjoy watching the competition. In between rounds, you are walking around the contest area when you see a toddler, one of the contestants, playing with her blocks. Annoyed that she is ...
app_data_2719
Joana Vasconcelos is a Portuguese artist who uses everyday objects in her creations, like electric irons or plastic cutlery. She is an inspiration to Ana, who wants to make ceiling hanging sculptures with straight knitting needles and balls of wool. For safety reasons, there will be a ball at each end of each needle. K...
app_data_2720
Given an orthogonal maze rotated $45$ degrees and drawn with forward and backward slash characters (see below), determine the minimum number of walls that need to be removed to ensure it is possible to escape outside of the maze from every region of the (possibly disconnected) maze. /\ \/ This maze has only a single ...
app_data_2721
Farmer Laura has a barn. In her barn, she has two cows, Monica and Lydia. Monica and Lydia love food, and they are quite lazy. For most of the day they chill out in the barn, waiting for Laura to come serve them a nice meal. Farmer Laura is always very precise about when to serve them food, so Monica and Lydia know exa...
app_data_2722
Robot Turtles is one of Theta’s favorite games. In this game, kindergarteners learn how to “code” by creating programs that move a turtle from a starting field to a diamond. Robot Turtles is reportedly the most successful game funded by the Kickstarter incubator. Players must develop a program consisting of “instructi...
app_data_2723
The ZOO management had been wondering for a long time how to increase the number of children visitors to the ZOO. The solution was surprising and unexpected in many ways. They installed a huge screen past the entrance and started to display short quizzes on it. The child in the crowd who first shouts out the answer to ...
app_data_2724
You are the founder of the Bruce Arden Programming Collective, which is a tutoring programme that matches experienced programmers with newbies to teach them. You have $N$ students and $N$ tutors, but now you have to match them up. Since the students will have to travel to their tutors’ houses from their own (or vice ve...
app_data_2725
One of the most difficult things about going on a holiday is making sure your luggage does not exceed the maximum weight. You, chairman of the Backpacker’s Association for Packing Carry-ons, are faced with exactly this problem. You are going on a lovely holiday with one of your friends, but now most of your time is spe...
app_data_2726
Jacob is playing a very odd solo card game called StopCard. In this game, the deck consists of $n$ cards where every card has one unique integer written on one side of it. The deck is shuffled randomly before the game is played. During each turn of the game, Jacob can choose to either take a card off the top of the dec...
app_data_2727
Given a permutation $A = (a_1, a_2, \dots , a_ N)$ of the integers $1, 2, \dots , N$, we define the greedily increasing subsequence (GIS) in the following way. Let $g_1 = a_1$. For every $i > 1$, let $g_ i$ be the leftmost integer in $A$ that is strictly larger than $g_{i-1}$. If for a given $i$ there is no such integ...
app_data_2728
You and your classmates are going on an exciting field trip to a downtown museum. Because the museum is an hour away, three buses of identical capacity and a van are dispatched as a means of transportation to the museum and back. The buses will first start loading only students, and once all students have been loaded t...
app_data_2729
Dividing two numbers and computing the decimals is an extremely difficult task. Luckily, dividing a number by a “special” number is very easy (at least for us humans)! We will define the set of “special” numbers $S=\{ 10^K\} $ for all non-negative integers $K$, i.e. $\{ 1,10,100,\ldots \} $. Given a large numbers $N$...
app_data_2730
Yes! You’ve finally been chosen to participate in the "Great Geek Game-show 3000". This is the moment you’ve been waiting for, ever since you puzzled out how to maximise your chances of winning. You will finally be rich, and able to buy all the algorithm books you want! Of course you will have to share the winnings wit...
app_data_2731
An array in a certain programming language is defined in the following way: - The beginning and the end of an array is denoted by an open and closed curly bracket, respectively. - Inside the curly braces, there are (possibly even 0) values separated by a comma (there is no comma after the last value in the array). -...
app_data_2732
Agneta and Beata are visiting the famous Swedish Amusement Park of Infinite Fun and Games. Their favourite attraction is the Infinitely Long Slides. Each slide can be viewed as an infinitely long, completely vertical spiral of radius $1$. When projected into the (flat) ground, the first slide has $(0, 0)$ as its centr...
app_data_2733
In this problem, we are simulating the dynamics of moving objects. The objects are droplets that are modeled in two dimensions as circles of various sizes, each moving at a constant velocity. When two circles touch they combine (i.e., agglomerate) into a single circular droplet with an area equal to the sum of the area...
app_data_2734
Alice and Bob have an integer $N$. Alice and Bob are not happy with their integer. Last night they went to a cocktail party and found that another couple had the exact same integer! Because of that they are getting a new integer. Bob wants to impress the other couple and therefore he thinks their new integer should be...
app_data_2735
Illiteracy is a simple puzzle game created by Le Sio. 1 The game consists of a sequence of eight icons; the actual icons are very artistic, but for simplicity, we’ll label the icons using a capital letter A—F. Clicking any icon has a unique effect on the other icons, based on which icon is clicked and that icon’s posit...
app_data_2736
After seeing all the beautiful landscaping around Cossin, Yraglac is inspired to work on his own gardening. Since food is such a scarce commodity on Mars, he decides it would be nice to plant an agricultural crop: Martian rice. The unique thing about Martian rice is that it will only grow in flat areas where water can ...
app_data_2737
After Curiosity discovered not just water on Mars, but also an aggressive, bloodthirsty bunch of aliens, the Louvain-la-Neuve municipal government decided to take precautionary measures; they built shelters in order to shelter everyone in the city in the event of an extraterrestial attack. Several alien-proof shelters...
app_data_2738
A set of gears is installed on the plane. You are given the center coordinate and radius of each gear, which are all integer-valued. For a given source and target gear, indicate what happens to the target gear if you attempt to turn the source gear. Possibilities are: - The source gear cannot move, because it would dr...
app_data_2739
A scientist, E. Collie, is going to do some experiments with bacteria. Right now, she has one bacterium. She already knows that this species of bacteria doubles itself every hour. Hence, after one hour there will be $2$ bacteria. E. Collie will do one experiment every hour, for $n$ consecutive hours. She starts the fi...
app_data_2740
An artist begins with a roll of ribbon, one inch wide. She clips it into pieces of various integral lengths, then aligns them with the bottom of a frame, rising vertically in columns, to form a mountain scene. A mountain scene must be uneven; if all columns are the same height, it’s a plain scene, not a mountain scene!...
app_data_2741
Ever wonder what will happen when you meet a person who uses a different base system to talk about numbers? For example, when you hear someone saying this mysterious number 1010110001 (which is in binary), can you quickly convert it to its decimal form, 689? In Harkerland, everyone uses the octal numeral system (base ...
app_data_2742
You have recently acquired a new job at the Bank for Acquiring Peculiar Currencies. Here people can make payments, and deposit or withdraw money in all kinds of strange currencies. At your first day on the job you help a customer from Nijmegia, a small insignificant country famous for its enormous coins with values equ...
app_data_2743
You have recently been hired as an architect for the BAPC (Bureau of Architecture and Promising Constructions), responsible for top-quality buildings such as the Tower of Pisa. However, in the past couple of weeks, some of the structures that the BAPC have made have collapsed! It is up to you to figure out whether any ...
app_data_2744
Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well. There are n cities in Berland. People can travel between cities using two-directional train routes; there are exactly m routes, i-th route can be used to go from c...
app_data_2745
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. Example 1: Input: s = "barfoothefoobarman", words = ["foo","bar"] Output: [0,9] Exp...
app_data_2746
Compare two version numbers version1 and version2. If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may assume that the version strings are non-empty and contain only digits and the . character. The . character does not represent a decimal point and is used to separate number s...
app_data_2747
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4]...
app_data_2748
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Example: Input: "23" Output: ["ad", "ae", "af", "bd", "be", "bf"...
app_data_2749
We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied: - For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W. - For each i (1 ≤ i ≤ N), the squares painted ...
app_data_2750
Consider a sequence $A$ of integers, containing $N$ integers between $1$ and $N$. Each integer appears exactly once in the sequence. A subsequence of $A$ is a sequence obtained by removing some (possibly none) numbers from the beginning of $A$, and then from the end of $A$. Calculate how many different subsequences o...
app_data_2751
Mirko’s great grandmother Katica is an avid mathematician. She likes to torment Mirko with math games. This time she wrote down a sequence of numbers on a piece of paper and told Mirko he may do the following: - Choose any two numbers in the sequence (let’s call them $A$ and $B$) and a prime number $X$ such that $A$ i...
app_data_2752
Gregory Brandon Sr. works at some startup in Redmond that owns a huge campus with a lot of office buildings. Since Gregory likes to work in different environments, he will work in exactly two buildings every day. On the $i$-th day, Gregory walks from his home to building $a_ i$ in the morning, walks from building $a_ i...
app_data_2753
Ivica and Marica are attending astronomy classes and are observing two unusual stars. They noted the time when each of them flashed. They further noticed that each of the stars flashes periodically, at regular intervals, and now they are wondering: on what day, at what hour will the stars flash at the same minute for t...
app_data_2754
An instructor may use curved score to grade a student’s performance. Assume a student’s original score is $x$ out of a total of $100$. One of the curving methods is to apply to $x$ the curving function $f(x) = 10\sqrt {x}$. The function may be applied $k \geq 0$ times. For better score readability, the result is rounde...
app_data_2755
Bees are one of the most industrious insects. Since they collect nectar and pollen from flowers, they have to rely on the trees in the forest. For simplicity they numbered the $n$ trees from $0$ to $n - 1$. Instead of roaming around all over the forest, they use a particular list of paths. A path is based on two trees,...
app_data_2756
During the COVID-19 quarantine, Theta discovered Minecraft Dungeons which is an offshoot of the popular Minecraft game. In Minecraft Dungeons, players crawl through a dungeon, trying to accomplish a mission without getting killed by various mobs. At the end, a boss battle with the Arch-Illager awaits. Fortunately, the...
app_data_2757
Let $x_0, \ldots , x_{n-1}$ denote $n$ boolean variables (i.e., variables taking only values $0$ and $1$). A binary decision diagram (BDD) over these variables is a diagrammatic representation of a boolean function $f(x_0, \ldots , x_{n-1})$ as inputs. A BDD is a rooted binary tree such that all internal vertices $v$ ...
app_data_2758
The color of a cat is primarily decided by three genes, coding for Black (Eumelanin), Red (Phaeomelanin) and Dilution (Melanophilin). The cat genetics experts among the readers will note that we are ignoring a wide range of genes, e.g., Tyrosinase and the white masking gene – we apologize in advance for the oversimplif...
app_data_2759
Mirko found a collection of $N$ toy tanks dating back to the Second World War on his grandfather’s attic. He promptly called his friend Slavko to play with him. They made a battlefield – a wooden board consisting of squares in $N$ rows and $N$ columns. Each tank can be moved to one of the four neighbouring squares in ...
app_data_2760
Frane has been given the task of sorting an array of numbers. The array consists of $N$ integers, each between $1$ and $N$ (inclusive), with each of those appearing exactly once in the array. Frane has come up with the following sorting algorithm which operates in $N$ phases, and named it turbosort: - In the first pha...
app_data_2761
Three infinite lines define a triangle, unless they meet at a common point or some of them are parallel. Given a collection of infinite lines, what is the largest possible perimeter of a triangle defined by some three lines in the collection? -----Input----- The first line of input contains a single integer $n$ ($3 \...
app_data_2762
In order to build a staircase to a famous pagoda on top of a mountain, the local authority has identified $N$ positions along the mountain slope $a_1, a_2, \ldots , a_ N$ where $a_ i$ is the height of the $i$-th position and $a_ i \leq a_{i+1}$ for all $0<i<N$. The cost to build a staircase from position $i$ to positi...
app_data_2763
The grille cipher  is a technique that dates back to 1550 when it was first described by Girolamo Cardano. The version we’ll be dealing with comes from the late 1800’s and works as follows. The message to be encoded is written on an $n \times n$ grid row-wise, top to bottom, and is overlaid with a card with a set of ho...
app_data_2764
Robot Turtles is one of Theta’s favorite games. In this game, kindergarteners learn how to “code” by creating programs that move a turtle from a starting field to a diamond. Robot Turtles is reportedly the most successful game funded by the Kickstarter incubator. In the actual board game, an adult plays the role of th...
app_data_2765
A coin system $S$ is a finite (nonempty) set of distinct positive integers corresponding to coin values, also called denominations, in a real or imagined monetary system. For example, the coin system in common use in Canada is $\{ 1,5,10,25,100,200\} $, where $1$ corresponds to a $1$-cent coin and $200$ corresponds to ...
app_data_2766
You and your friends at the Betting against All Probability Club are visiting a casino where the following game is played. Each of the $n$ players starts with $k$ lives and puts in a fixed amount of money. In each round of the game, each player flips a biased coin and loses a life if she gets tails. The game ends when...
app_data_2767
Little Ivica got himself a summer job at a company that produces computer fonts. The branch of the company where Ivica works at specialises in testing computer fonts and Ivica’s team is responsible of testing only lowercase letters of the English alphabet. The letters are tested so that various sentences using those l...
app_data_2768
In the nearby kindergarten they recently made up an attractive game of strength and agility that kids love. The surface for the game is a large flat area divided into $N \times N$ squares. The children lay large spongy cues onto the surface. The sides of the cubes are the same length as the sides of the squares. When...
app_data_2769
John is a leading organizer of this year’s North America ICPC training camp. The camp lasts several days. On each day, there will be a lecture introducing two problems: one classical problem and one creative problem. Each problem can only be introduced once during the entire camp. Every problem has an integer difficult...
app_data_2770
-----Input----- The first line of input contains an integer $1 \le N \le 40$, the degree of the recurrence. The next line of input contains $N+1$ integers $a_0, a_1, \ldots , a_ N$ indicating that the linear recurrence is $x_{t} = a_0 + \sum _{i=1}^N a_ i x_{t-i}$. The next line contains $N$ integers $x_0, \ldots , x_{...
app_data_2771
With modern technology advancement, it is now possible to deliver mail with a robot! There is a neighborhood on a long horizontal road, on which there are $n$ houses numbered $1$ to $n$ from left to right. Every day a mail delivery robot receives a pile of letters with exactly one letter for each house. Due to mechanic...
app_data_2772
The following puzzle was popularized by Martin Gardner’s book “My Best Mathematical and Logic Puzzles,” although it appears first in the monograph “On Problem-Solving” by the Gestalt psychologist Karl Dunker. One morning, exactly at sunrise, a Buddhist monk began to climb a tall mountain. The narrow path, no more than...
app_data_2773
After last year’s edition of the BAPC, you are still stuck in Delft. In order to participate again this year, you are going to Amsterdam by bus. During the journey you look out of the window and look for traffic signs that point in the direction of Amsterdam. To your surprise, you notice that the bus is never taking th...
app_data_2774
In the woods of Lill-Jansskogen, there is a network of trails that are often used by joggers. The trails have been much appreciated, and have been specially selected by the professors of the Royal Institute of Technology, enabling university students to take a short break from their studies and refresh their smart mind...
app_data_2775
As a New Yorker you are always very busy. Apart from your long work day you tend to have a very long list of errands that need to be done on any particular day. You really hate getting up early so you always end up going over your to-do list after work, but this is starting to seriously hurt your free time. One day yo...
app_data_2776
Everyone’s favorite character and puppet-maker Geppetto has opened a new pizza place, the best in town. Geppetto is trying to make the best pizza possible, but at the same time he doesn’t want to have a small selection of pizzas. He makes his pizzas out of $N$ ingredients marked with numbers from $1$ to $N$. All that ...
app_data_2777
Suppose you are given two integers, $m$ and $n$. You are also given a list of $n$ distinct integers $x_1, x_2, \ldots , x_ n$, with $0\! \le \! x_ i\! \le \! 2^m{-}1$. For each number $y$ from $0$ to $2^m{-}1$, you’ve found the number $p_ y$ such that $x_{p_ y}$ has a maximum bitwise-$\operatorname {XOR}$ with $y$. Tha...
app_data_2778
Johanna knows mind reading magic, or so she says. Her new trick consists of lining up $N$ decks of cards, each deck having $K$ cards numbered from $1$ to $K$. She asks you to think of a number $T$ between $1$ and $N \cdot K$ and to focus your thoughts on it. Then, by scanning the energy profiles emitted from your brain...
app_data_2779
The First Universal Bank of Denview has just been robbed! You want to catch the robbers before they leave the state. The state of Calirado can be represented by a rectangular $n$-by-$m$ grid of characters, with the character in each grid cell denoting a terrain type. The robbers begin within the cell marked ‘B’, indic...
app_data_2780
Prof. Peter decided to surprise his class by organizing a new lottery with a very peculiar system. He starts by announcing a small positive number $M$. Afterwards, each student is going to secretly write an integer from the set $\{ 1, ..., M\} $ on a slip of paper that is then folded. After everyone has selected a num...
app_data_2781
Liam is planning out his route for an upcoming nature hike. Unfortunately, the region that he plans on hiking through is notoriously muddy, so in order to prevent his floral shirt from getting covered with mud, he has decided to pick a route for which the maximum depth of mud encountered is minimized. The terrain is m...
app_data_2782
An airline called Divided Airlines has recently made the news due to their tendency to overbook their flights rather aggressively. For some flights, they even resorted to dragging passengers out from the plane! This was of course not very popular, so they decided to “resolve” the issue by making the seating assignments...
app_data_2783
Summer in Texas can be very hot. But Texans are tough, and in a weird way some of them enjoy the heat; for even the heat is bigger in Texas. But the heat can be quite uncomfortable for computer science students who are new to Texas and are not used to the sweating it can cause. These students want to minimize the amou...
app_data_2784
You have arrived in The Big City but your journey is not yet complete. You must still navigate the subway and get to your final destination. The information booth in the subway station is unattended and fresh out of maps of the subway system. On the floor you notice fragments of a map. Can you piece together enough of ...
app_data_2785
Being a responsible young adult, you have decided to start planning for retirement. Doing some back-of-the-envelope calculations, you figured out you need at least $M$ euros to retire comfortably. You are currently broke, but fortunately a generous gazillionaire friend has offered to lend you an arbitrary amount of mo...
app_data_2786
A regular bracket-sequence is a string of characters consisting only of opening and closing brackets, and satisfying the following conditions: - An empty string is a regular bracket-sequence. - If $A$ is a regular bracket-sequence, then ($A$), [$A$] and {$A$} are also regular bracket-sequences. - If $A$ and $B$ are ...
app_data_2787
At one of the many climate protests, Skylar fell in love with a fellow environmental activist. Unfortunately, the two young lovers live on opposite sides of the planet and long distance travel is only practical by (gasp) air. Skylar had scolded friends and family for flying, heavily handing out the recent Swedish expor...
app_data_2788
You are a camp counselor at a summer camp and it is time to take some of the kids to lunch. There are $n$ groups of friends of different sizes who would like to be able to eat lunch together. There are $k$ bins that each hold exactly $x$ lunches. If one of the lunches in a bin is not used, then it must be thrown out du...
app_data_2789
Mirko and Slavko’s favourite pastime is competing against each other in mathematical games. This time they took a heap of $N$ pebbles and settled on the following rules: - Mirko is the first to play, then Slavko, then Mirko again, then Slavko and so on; - Mirko can take any number of pebbles (between $1$ and $N$, inc...
app_data_2790
Gerald’s job is to welcome the teams for this year’s NWERC at the airport in Linköping. One of his duties is to stand at the luggage carousel and collect all the knapsacks that the teams are bringing. Gerald is a lazy person, so he just stands at the same position of the carousel and waits for bags to pass by so he can...
app_data_2791
In C++ division with positive integers always rounds down. Because of this, sometimes when two integers are divided by the same divisor they become equal even though they were originally not equal. For example in C++, $\verb|5/4|$ and $\verb|7/4|$ are both equal to 1, but $5 \neq 7$. Given a list of nonnegative intege...
app_data_2792
Han didn’t want to study solo so he invited his friend Dominik to come over. After an eventful evening that will be remembered for a record number of solved tasks from the field of electronics, Dominik went home. To his surprise, the police stopped him thinking he was drunk. It is known that in these situations sobriet...
app_data_2793
Given a directed weighted graph and two vertices $s$, $t$, the goal is to find a subset $U$ of the vertices such that $s \in U$, $t \not\in U$, and the weight of edges from $U$ to $\overline{U}$ is minimized. -----Input----- The first line of input contains four non-negative integers, $2 \le n \le 500$, $0 \le m \le 1...
app_data_2794
It’s another day in the office, and you’re a mastermind of not doing any work yourself. Instead, you’ll go to your coworkers for “help,” but secretly have them do all the work. You’ve determined that the more one of your coworkers helps you, the more annoyed they become. You’ve also been able to determine how much mor...
app_data_2795
In a rainforest there are $n$ treehouses high in the forest canopy on different trees (numbered from $1$ to $n$). The $i$-th tree’s location is at $(x_ i, y_ i)$. The first $e$ of them in the list are close enough to neighboring open land around the rainforest so that transportation between all of them is easy by foot....
app_data_2796
A long time ago in a galaxy far, far away, there were $N$ planets. There were also $N - 1$ interplanetary paths that connected all the planets (directly or indirectly). In other words, the network of planets and paths formed a tree. Additionally, each path was enumerated with an integer that denoted the curiosity of th...
app_data_2797
One day you and GTmac walk into a classroom and see a mysterious expression on the blackboard:\[ (1^b + 2^b + \cdots + a^b)~ \mathrm{mod}~ a \] Upon seeing the expression GTmac shows an evil smile and challenges you: “Let me give you the values of $a$ and $b$ and let’s assume $b$ is an odd number. Want to bet who can ...
app_data_2798
Ruben and Albert are what you can call abnormally smart. They are also both very fond of mathematically inspired games. Their only problem is that most games are too easy for them, and they end up beating everyone who dares challenge them. Because of that, they’re now mostly playing against each other. To make things i...
app_data_2799
First Orchard is a cooperative game for children 2 years and up. In this simple game, the players pick colored fruits from trees in an orchard and place them into a basket. To make the game more interesting, a raven tries to reach the orchard to steal the fruits. If the players are successful in moving all fruits into ...