task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
Permutacja (AE5B2) You are given a sequence of positive integers a 1 , a 2 , . . . , a n . We would like to order the numbers from 1 to n in such a way, that the i-th number is not greater than a i (for each i). In other words, we are looking for a permutation p of numbers from 1 to n, which satisfies: p i ≤ a i ...
31,700
Quasi-template (AE5A2) A template of a word v is such a word s that all occurrences of s within v cover the whole word v (i.e. each letter of the word v appears within some fragment of consecutive letters of v equal to s). By quasi-template of a word v we mean such a word s that s is a substring (i.e. a fragment of c...
31,701
Catch Fish (MFISH) English Vietnamese   During his childhood, Mirko liked to play “Sea battle” a lot, but once he got bored of it and invented a new game imaginatively called “Ships catch fish on a river”. The game board consists of N fields lined up in a row and numbered 1 to N in ascending order fro...
31,702
The fate of the pineapple (EVERLAST) In order to help terraform Mars, astronauts have brought (among other things) N (0<=N<5) young, healthy pineapple plants. This particular type of pineapple reproduces asexually in the following way: A single pineapple plant produces K (0<=K<15) new pineapple in one growing se...
31,703
Counting K-Rectangle (KRECT) English Vietnamese Given a M×N square board. Each square contains a letter of the English alphabet ('A' .. 'Z'). A K-rectangle of the board is a rectangle whose sides are parallel to the sides of the board, and contains exactly K different types of letter. For examp...
31,704
Empty Boxes (EBOXES) N large empty boxes (assume they are of type:1) are initially placed on a table. An unknown number of boxes (type:1) are selected and in each of them K smaller boxes (type:2) are placed. Again an unknown number of type:2 boxes are selected and K boxes of type:3 are placed inside. This pro...
31,705
Giá trị lớn nhất 3 (QMAX3VN) English Vietnamese Following the journey to explore the real power of special data stuctures, two adventurers pirate and duyhung123abc continued to find new challenges with new more and more complicated problems. But what they earned was unremarkable. Being tired and stucke...
31,706
Snowflakes (TWINSNOW) English Tiếng Việt You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read information about a collection of snowflakes, and search for a pair that may be identical. Each snowflake has six arms. ...
31,707
Connected Points (CONNECTE) English Vietnamese Consider a regular grid of 3 × N points. Every point in the grid has up to eight neighboring points (see figure 1). Figure 1: Neighboring points (marked by arrows). We are interested in counting the number of different ways to connect the points of the g...
31,708
Twofive (TABLE5X5) English Tiếng Việt Having a 5×5-table, we make a right-table by filling letters from 'A'..'Y' into the table satisfying: Each letter is used exactly one time. The letters is ascending on every row. The letters is ascending on every column. Each right-table is described by a 25-leng...
31,709
Cards shuffing (CARDSHUF) English Tiếng Việt "Phú ông" has a card deck consits of n cards. He writes on each card a number from 1 to n from the top to the bottom of the deck. Then he does shuffle the card deck several times, each time is described by S(i, j) meaning: pull out the i th card then put it...
31,710
Counting Arborescence (DAGCNT) "In graph theory, an arborescence is a directed graph in which, for a vertex v called the root and any other vertex u, there is exactly one directed path from v to u. In other words, an arborescence is a directed, rooted tree in which all edges point away from the root. Every arborescenc...
31,711
Build a Fence (FENCE1) There is a wall in your backyard. It is so long that you can’t see its endpoints. You want to build a fence of length L such that the area enclosed between the wall and the fence is maximized. The fence can be of arbitrary shape, but only its two endpoints may touch the wall. Input The inp...
31,712
Circle vs Triangle (AREA1) You are given a triangle and a circle in a plane. You can arbitrarily rotate or move them. What's the maximum possible area of their overlapping region? Input Input consists of one or more lines. For each line, there are four integers describing one test case: the lengths of three sides ...
31,713
Repair the Door (REPAIR1) Once upon a time, there was a famous university called Famous University. As thousands of students studied and lived in FU, a gigantic residential building was built, which is called 'B37'. All students lived in B37 happily. After decades, FU is still as famous as it had been in the past; h...
31,714
Counting Expressions (EXPR3) Count the number of distinct expressions involving n different operands a , b , c , etc. Only operators +, -, *, / and parentheses are permitted. Single minus operator (for ex. -a*b) is not allowed. Two expression are distinct if for some valid input values (i.e. You won't divide so...
31,715
Factorization, Factorization, Factorization (FACTOR1) Factorize x n -1 into several irreducible polynomials over the integers. Input Multiple test cases. For each test case: A single line - n . (2 ≤ n ≤ 1200). Input terminates by a single zero. Output For each test case, output the factorization of th...
31,716
Gem (GEM) You are given a board with 8×8 squares. In each square, there can be either a colored gem or no gem at all. Gems with different colors are represented by different integers. It is guaranteed that there are no more than two consecutive gems with the same color either in a row or in a column. ........ ........
31,717
Highway (HIGHWAY1) As we all know, every day, there are hundreds of trucks passing through the highway. As some of the trucks might carry several tons of goods, the highway will be damaged unless it is frequently repaired. The administration of highway is worried about this, so it invented repairing cars to ensure tha...
31,718
Power of Integer (INTEGER1) For a given positive integer y ( y > 1), if we can find a largest integer k and a smallest positive integer x , such that x^k=y , then the power of y is regarded as k . Calculate the sum of the power of the integers from a to b. (2<= a <= b <=10 18 ) Input The input consis...
31,719
Jumping Hands (JUMP1) In Shanghai, there are some famous clock towers built more than 100 years ago, such as the office building of Shanghai Customs, Xujiahui Church, etc. Every clock tower’s clock-face consists of three hands: an hour hand, a minute hand, and a second hand. The hands are not move smoothly as time pas...
31,720
Counting Graphs (KPGRAPHS) In this problem your task is to count the amount of graphs of different types. We only consider undirected graphs without self-loops. Every pair of vertices can be connected with at most one edge. Graphs are labeled, i.e. if a graph has N vertices, then each of them has a unique label from 1...
31,721
Irreducible polynomials over GF2 (GF2) Find the number of degree n irreducible polynomials over GF(2). For example: for n=1 there are two such polynomials: x and x+1. For n=2 there is only one: x 2 +x+1. Note that in R[x] the polynomials x 2 +1 is irreducible, but not over GF(2), because x 2 +1 = (x+1)*(x+1) Input...
31,722
Spelling Lists (MIB) J, of the Men In Black,  has been learning an alien language and has has a spelling test tomorrow.  J, however, is bored of studying the nonsensical (and often unpronouncable) words. Instead, he is seeing how many ways he can reorder his spelling list.  After making all possible permutations of ...
31,723
Simple Arithmetics II (ARITH2) While browsing aimlessly, Peter stumbled upon an old riddle he used to solve on his calculator when he was still young. It was the kind of a riddle where you punch in a bunch of numbers and operators into a simple pocket calculator and then turn it upside down to get the answer: These ...
31,724
Bouncing Balls II (BOBALLS2) "Behold, my queen", said the jester, "the great Bouncing Ball Bowl!" The queen boredly waved her hand and sarcastically replied: "Let the fun begin!". And the fun begun! The jester spoke a magic word and all the colorful balls in his bowl started to roll and bounce, creating interesting pi...
31,725
Brackets II (BRCKTS2) Peter is preparing slides for his lecture on parsing arithmetic expressions. In the first part of the lecture he wants to focus just on parsing brackets. He invented an interesting geometric representation of a correct bracket sequence for his students, because one image is better than a thousand...
31,726
Going to the Movies (MOVIE) N (N ≤ 120) friends decided to go to the local cinema together. They all bought tickets to the same row. As there was still some time left, each of them took her ticket and went shopping until the movie starts. They all arrived back late, the movie already started. The usher standing at t...
31,727
Jumbo Airlines (AIRLINES) The new catchphrase of Jumbo Airlines is "No annoying neighbors, each flight a unique experience!" And as in most cases, the advertisement was produced by the marketing department, without ever consulting the engineers. They only learned about it after the boss asked them to "handle it ASAP...
31,728
Shopping II (SHOP2) Karl is going to spend his holiday in Nothingland. Since there is nothing there, he has to buy all supplies now. At the moment, he is waiting at the checkout counter with a shopping cart full of stuff. Of course, he has a sufficient amount of money in his wallet. However, he prefers to use altern...
31,729
Rainbow (RAINBOW2) This time Blue Mary continues doing meaningless calculations! (see problem SPY ) She is interested in calculating the K -th power of a very large N x N matrix A, where A i,j = i * D + Q j i and j are 0-based index of the row and column of element A i,j , respectively. Now she needs y...
31,730
Muzidabutur (MUZIDA) Given a string S of lowercase Latin letters. You are to answer Q queries: given l and r (1 <= l <= r <= | S |), count the number of distinct non-empty subsequences of the substring S [ l .. r ]. Input Multiple test cases. For each test case: The first line of input contains a st...
31,731
A Famous Airport Manager (AIRLINE2) Mr. B is an airport manager. One day after lunch he looked out from his office and found that the color of each plane which was currently parked in the airport is either blue or green. Before supper he found that no plane is on the airport now. He couldn't remember the orders in...
31,732
The Ant (ANTTT) There are n sticks lying on the ground. The Ant can move only along the sticks. It can go from one stick to another only if the sticks intersect or touch each other. Help the Ant find out if it can reach the stick y from the stick x . Input The first line of the input contains number t – th...
31,733
Flower growing (FLOWGROW) English Tiếng Việt The farmer AnhDQ grows flower in his MxN garden (M rows and N columns). He wants to grow flower satisfying that: Each row of the garden has at least k color(s) of flower; and he has 7 types of flower: red, orange, yellow, green, blue, indigo, and violet to use. ...
31,734
Counting Expressions II (EXPR4) Count the number of distinct expressions involving n different operands a , b , c , etc. Only operators +, -, *, / and parentheses are permitted. Single minus operator (for example -a*b) is not allowed. Two expression are distinct if for some valid input values (i.e. You won't di...
31,735
Chaos Strings (MCHAOS) English Vietnamese Little Lovro likes to play games with words. During the last few weeks he realized that some words don't like each other. The words A and B don't like each other if the word A is lexicographically before the word B, but the word B' is lexicographically before the...
31,736
Roads Repair (MROADS) English Vietnamese The traffic network in a country consists of N cities (labeled with integers 1 to N) and N-1 roads connecting the cities. There is a unique path between each pair of different cities. Because of the many years of lazy maintenance the roads are pretty damaged and f...
31,737
MobiZone vs VinaGone (MOBIVINA) English Tiếng Việt KTuan and AnhDQ, CEOs of two telecommunication corporations MobiZone and VinaGone have signed a contract to use their network in common. N people have accepted to try this new service. The i th people accepts to pay M i to use MobiZone's service or V i ...
31,738
Can you answer these queries VI (GSS6) Given a sequence A of N (N <= 100000) integers, you have to apply Q (Q <= 100000) operations: Insert, delete, replace an element, find the maximum contiguous(non empty) sum in a given interval. Input The first line of the input contains an integer N. The following line co...
31,739
Primes in GCD Table (PGCD) Johnny has created a table which encodes the results of some operation -- a function of two arguments. But instead of a boring multiplication table of the sort you learn by heart at prep-school, he has created a GCD (greatest common divisor) table! So he now has a table (of height a and wi...
31,740
Binomial Coefficients (UCI2009B) We all got too excited when we learned (A + B)^2 = A^2 + 2AB + B^2. After solving this problem, maybe you could get even more excited because you will have to calculate (A + B)^N, where (0 ≤ N ≤ 1000). Follow the rules below when giving the answer: Consecutive terms must be separ...
31,741
Digger Octaves (UCI2009D) After many years spent playing Digger, little Ivan realized he was not taking advantage of the octaves. Oops, sorry! Most of you were not born when Digger came to light! Digger is a Canadian computer game, originally designed for the IBM personal computer, back in 1983. The aim of the game ...
31,742
Frog Wrestling (FROGS) Billy Jean loves collecting frogs.  Recently, she developed the sport of frog wrestling.  Now she wants to rank her frogs by their wrestling prowess. Billy Jean has made an algorithm for sorting her frogs. She arranges N cages, numbered 1,2,...N, each with one frog. For each pair of cage...
31,743
String reduction (STREDUCE) English Tiếng Việt Given a string containing only characters of 'a' and 'b'. You can reduce this string by replacing a substring forming a?a or b?b by ?; ? is 'a' or 'b'. Request Find a way to minimize the length of given string by reducing it. Output that minimum length. ...
31,744
Determinant of Banded Matrices (BANDMATR) Computing the determinant of a matrix using Gaussian elimination takes O(n^3). On the other hand, computing the determinant of tridiagonal matrix is O(n) using a recurrence. In this problem you will compute the determinant of banded matrices. A band matrix is a sparse matrix, ...
31,745
Tobo or not Tobo (ANARC08A) The game of Tobo is played on a plastic board designed into a 3X3 grid with cells numbered from 1 to 9 as shown in figure (a). The grid has four dials (labeled 'A' to 'D' in the figure.) Each dial can be rotated in 90 degrees increment in either direction. Rotating a dial causes the four ce...
31,746
Adding Sevens (ANARC08B) A seven segment display, similar to the one shown on the right, is composed of seven light-emitting elements. Individually on or off, they can be combined to produce 127 different combinations, including the ten Arabic numerals. The figure below illustrates how the ten numerals are displayed. ...
31,747
Match Maker (ANARC08C) In Computer Science, pattern matching is the act of checking if a certain sequence conforms (matches) a given pattern. Patterns are usually specified using a language based on regular expression. In this problem, we'll use a simple regular expression to express patterns on sequences of decimal d...
31,748
Adding up Triangles (ANARC08D) Take a look at the triangle on the left of the figure below. It is made of 9 (unit) triangles arranged in three rows (N = 3). Needless to say, a unit triangle is a triangle with N = 1. If you study the figure for few seconds, you'll realize that you can find 13 different triangles (w...
31,749
Einbahnstrasse (ANARC08F) Einbahnstrasse (German for a one-way street) is a street on which vehicles should only move in one direction. One reason for having one-way streets is to facilitate a smoother flow of traffic through crowded areas. This is useful in city centers, especially old cities like Cairo and Damascus....
31,750
Think I will Buy Me a Football Team (ANARC08G) Falling Stocks. Bankrupted companies. Banks with no Cash. Seems like the best time to invest: "Think I'll buy me a football team!" No seriously, I think I have the solution to at least the problem of cash in banks. Banks nowadays are all owing each other great amounts o...
31,751
Musical Chairs (ANARC08H) In the traditional game of Musical Chairs, N + 1 children run around N chairs (placed in a circle) as long as music is playing. The moment the music stops, children run and try to sit on an available chair. The child still standing leaves the game, a chair is removed, and the game continues w...
31,752
I Speak Whales (ANARC08I) According to Wikipedia, a Walsh matrix is a specific square matrix, with dimensions equal to a power of 2, the entries of which are +1 or -1, and the property that the dot product of any two distinct rows (or columns) is zero. Below are the first three Walsh Matrices. (The gray lines are imag...
31,753
A Day at the Races (ANARC08J) Formula One is the highest class of car racing sports. A typical Formula One season consists of a series of races called "Grands Prix" which constructors like Ferrari, Renault, etc. and others participate with one or more cars driven by the best drivers in the world. During the season, te...
31,754
The Double HeLiX (ANARC05B) Two finite, strictly increasing, integer sequences are given. Any common integer between the two sequences constitute an intersection point. Take for example the following two sequences where intersection points are printed in bold: First= 3 5 7 9 20 25 30 40 55 56 57 60 62 Sec...
31,755
Chop Ahoy! Revisited! (ANARC05H) Given a non-empty string composed of digits only, we may group these digits into sub-groups (but maintaining their original order) if, for every sub-group but the last one, the sum of the digits in a sub-group is less than or equal to the sum of the digits in the sub-group immediately ...
31,756
What is your Logo (ANARC05I) Imagine a 2D diagram drawn in the following way: Starting at the origin, you're given a sequence of letters which is entirely made of the following four letters 'U', 'D', 'L', and 'R'. A 'U' is an instruction for you to move one unit upward and drawing a segment at the same time. Similarly...
31,757
Rotating Rings (ANARC07C) Any square grid can be viewed as one or more rings, one inside the other. For example, as shown in figure (a), a 5 × 5 grid is made of three rings, numbered 1, 2 and 3 (from outside to inside.) A square grid of size N is said to be sorted, if it includes the values from 1 to N 2 in a row-majo...
31,758
Let go to the movies (ANARC07G) A favorite pastime for big families in Acmestan is going to the movies. It is quite common to see a number of these multi-generation families going together to watch a movie. Movie theaters in Acmestan have two types of tickets: A single ticket is for exactly one person while a family t...
31,759
Riding in cycles (CYCLERUN) There are N cities, numbered from 1 to N, in the country you are living. Each pair of the cities is connected with exactly one road. However, each road is a one-way road , so it is either possible to go directly from A to B or from B to A for each pair of cities (A, B). You are living ...
31,760
ABCDEF (ABCDEF) You are given a set S of integers between -30000 and 30000 (inclusive). Find the total number of sextuples  that satisfy:    Input The first line contains integer N (1 ≤ N ≤ 100), the size of a set S. Elements of S are given in the next N lines, one integer per line. Given numbers will be ...
31,761
Star Wars (GCJ08C) Near the planet Mars, in a faraway galaxy eerily similar to our own, there is a fight to the death between the imperial forces and the rebels. The rebel army has N ships which we will consider as points (xi, yi, zi). Each ship has a receiver with power pi. The rebel army needs to be able to send mes...
31,762
Texas Trip (WLOO0707) After a day trip with his friend Dick, Harry noticed a strange pattern of tiny holes in the door of his SUV. The local American Tire store sells fiberglass patching material only in square sheets. What is the smallest patch that Harry needs to fix his door? Assume that the holes are points on...
31,763
Electric Fences (FENCE3) Farmer John has decided to construct electric fences. He has fenced his fields into a number of bizarre shapes and now must find the optimal place to locate the electrical supply to each of the fences. A single wire must run from some point on each and every fence to the source of electricit...
31,764
SETI (NWERC04H) For some years, quite a lot of work has been put into listening to electromagnetic radio signals received from space, in order to understand what civilizations in distant galaxies might be trying to tell us. One signal source that has been of particular interest to the scientists at Universit´e de Tech...
31,765
Arithmetic sequence (ARITHSEQ) English Tiếng Việt Given an arithmetic sequence a, a + d, a + 2*d, ..., a + n*d. Request Count the number of digit x appearing in the given sequence. Input - A line containing a, d, n, x. Output - The result found. Example Input: 10 5 2 0 Ou...
31,766
Proving Equivalences (PMATRIX) Consider the following exercise, found in a generic linear algebra textbook. Let A be an n × n matrix. Prove that the following statements are equivalent: (a) A is invertible. (b) Ax = b has exactly one solution for every n × 1 matrix b. (c) Ax = b is consistent for every n × 1 m...
31,767
Cross Mountain Climb (CCROSS) Somewhere in the neighborhood we have a very nice mountain that gives a splendid view over the surrounding area. There is one problem though: climbing this mountain is very difficult, because of rather large height differences. To make more people able to climb the mountain and enjoy the ...
31,768
Gas Wars (GASWARS) As the result of the gas wars the following agreement was made. The transit of the gas was allowed under the following conditions. There are n transit nodes and m pipes connecting those nodes. There k nodes where the gas enters and l nodes where it should be moved. Each pipe has a carrying c...
31,769
Help Hemant Verma (HHEMANT) Steganography is a method of cryptography where a message or entire document can be hidden inside of another file or image which shows no evidence that there is data hidden in it. Typically, the message or document to be sent is first encrypted and compressed, and then combined with an exis...
31,770
Wireless (WIRELESS) Bob is sitting at home with his computer. He would like to experience more social interaction, so he is planning a trip to a coffee shop with his computer. Bob has lots of data about wireless networks and coffee shops in the city. In Bob’s city, there is one coffee shop at every intersection of s...
31,771
Gremlins (GREMLINS) Gremlins are small funny furry creatures. Once they were considered to be evil but that time has past and most gremlins live a decent family life now. There are N distinct types of gremlins. Their origin is rather mysterious. Legend says that T years ago, N gremlins, one of each type, were born i...
31,772
Cross Mountain Climb Extreme (CCROSSX) Somewhere in the neighborhood we have a very nice mountain that gives a splendid view over the surrounding area. There is one problem though: climbing this mountain is very difficult, because of rather large height differences. To make more people able to climb the mountain and e...
31,773
Yanu in Movie theatre (FUNPROB) Yanu is a great fan of Harry Potter. So on the day of the movie release, Yanu rushes to the movie theatre to watch the movie. On the release of the 6th movie, on reaching the theatre she found a long queue for tickets already. As the distribution was about to start, the ticket counter d...
31,774
Twice (TWICE) Given a string S, find the longest substring that appears at least twice in S (occurrences may overlap). Input The first line contains an integer L (1 ≤ L ≤ 200000), the length of S. The second line contains the string S, consisting of exactly L lowercase letters ('a'-'z'). Output Output the le...
31,775
Grid Points in a Triangle (GPINTRI) How many points (x, y) with non-negative integer coordinates satisfy y ≤ ax / b and x ≤ n? Input The first line contains an integer T (T ≤ 100000). T lines follow, each contains three positive integers n, a, b, where n, a, b ≤ 10 9 and a ≤ b. Output T lines, each contains a...
31,776
Strategy game (HS09GAME) Julia and Robert are playing a game, in which they pick up sticks from heaps. The game starts with n heaps, the i -th heap contains a [ i ] sticks. In each turn the players choose a heap and take away 2, 3 or 5 sticks from it (removed sticks do not return to the game). Julia starts the gam...
31,777
Diophantine equation (HS09EQ) Sometimes solving a Diophantine equation is very hard. But, for example, the equation  a + b 2 + c 3 + d 4 = n has a trivial solution for every value of n . Your task is to determine the number of solutions of the equation for each given n , assuming that in the equation all the ...
31,778
Starship (HS09SHIP) You are traveling by starship and at any time you are always moving in one of 6 directions: forwards, backwards, up, down, left, or right. In other words, during every second, one of the three coordinates of your position changes by exactly one unit. Let us suppose that you are at ( x 1 , y 1 , ...
31,779
ZSequence (ZSEQ) You will be given a sequence A containing N positive integers, a 1 , a 2 ... a N . Let S(i, j) = a i + a i + 1 + ... + a j , if i <= j. You should find K - 1 indexes, m 1 < m 2 < ... < m K - 1 such that lb 1 <= S(1, m 1 ) <= ub 1 ... lb i <= S(m i - 1 + 1, m i ) <=...
31,780
Ant (PA06ANT) English Tiếng Việt A Byteotian ant is walking along the edges of ABCDEFGH cube: It tries to find out, in how many ways it can go from one given vertex, to another given vertex, walking along exactly k edges (when the ant enters an edge, it will not turn back and will finally reach th...
31,781
Bridge (BRI) Find a place to build a bridge over the river, so as to minimize total cost of the route between two cities A and B, located on opposite sides of the river. Input There is a single positive integer T on the first line of input (equal to about 100000). It stands for the number of test cases to fo...
31,782
Words on graphs (AMBIG) Input The input is a directed (multi)graph. The first line gives the number of edges M and the number of nodes N (≥ 2). Then each edge is described by a line of the form "FROM TO LABEL". Nodes (FROM, TO) are numbers in the range 0 .. N-1 and labels are also numbers. All numbers in the inp...
31,783
Counting in a DAG (DAGCNT2) You are given a weighted DAG . For each vertex, calculate the sum of the weights of the vertices within its reach (including itself). Input The first line contains an integer T, denoting the number of test cases. For each test case, the first line contains two positive integers n and...
31,784
Run-Length Mathematics (RLM) Run-length encoding of a number replaces a run of digits (that is, a sequence of consecutive equivalent digits) with the number of digits followed by the digit itself. For example, 44455 would become 3425 (three fours, two fives). Note that run-length encoding does not necessarily shorten ...
31,785
Integer Factorization (20 digits) (FACT1) This is a problem to test the robustness of your Integer Factorization algorithm. Given some integers, you need to factor them into product of prime numbers. The largest integer given in the input file has 20 digits. FACT2 is a harder version of this problem (the ...
31,786
Integer Factorization (15 digits) (FACT0) This is a problem to test the robustness of your Integer Factorization algorithm. Given some integers, you need to factor them into product of prime numbers. The largest integer given in the input file has 15 digits. FACT1 is a harder version of this problem (the ...
31,787
Integer Factorization (29 digits) (FACT2) This is a problem to test the robustness of your Integer Factorization algorithm. Given some integers, you need to factor them into product of prime numbers. The largest integer given in the input file has 29 digits. You may need to use a general factorization al...
31,788
Bridges! More bridges! (BRII) Problem BRIDGE has shown that you are able to build the cheap bridge through the river very quickly. Now you will not have problems with time limit. You will have problems with number of bridges. Input There is a single positive integer T on the first line of input. It stands fo...
31,789
Goal for Raúl (GOALFR) Goal for Raúl What would a Madrid programming contest be without some task about Real Madrid? It's a team with a marvellous history of records. For example, the team's topscorer Raúl González has scored 318 goals so far (in 704 games). In this task you are going to help Raúl shoot his 319th. C...
31,790
Madrids One Way Streets (MOWS) As you know, PolyProg wants to send EPFL's best coders to Madrid. Now an important question that arises is where they should stay. Apart from being a cheap place, it should also be close to the contest location and the main tourist spots. Now the problem is that there are mostly one-way ...
31,791
Traveling Salesman (FAKETSP) According to Wikipedia, "The Traveling Salesman Problem (TSP) is a problem in combinatorial optimization studied in operations research and theoretical computer science. Given a list of cities and their pairwise distances, the task is to find a shortest possible tour that visits each city ...
31,792
Lost in Madrid (LIM) Programming contests can be very exhausting. After five hours of intensive programming, you want to get some well-deserved rest and make yourself on the way to your hotel. Unfortunately, you don't quite remember the way to get there... but that doesn't matter: In good spirits (due to a successful ...
31,793
Library for Madrid (LFM) Good preparation is essential for winning programming contests. Thus, if you read this document, you're on the right track ;) Knowing your algorithms and the programming language you use is of prime importance. However, you don't have to learn everything by heart; each team is allowed to bring...
31,794
Crazy Receptionist (CRAZYR) After having been wandering around Madrid for several hours, you finally reach the NH Zurbano hotel where all competitors will be located for the SWERC weekend. Each team received an ID number when it registered for SWERC. At your arrival, the receptionist at NH Zurbano asks you for that ID...
31,795
Decode the Castanets (CASTANET) The contest just finished and you head out to show all the balloons you won to your coach who’s amazed! Contest organizers know that coders can get really excited during the five hours of contest, so they planned to take you to a flamenco performance in order to relax you a bit before t...
31,796
Guernica (GUERNICA) Guernica is a famous painting by Pablo Picasso, depicting the bombing of the Basque town of Guernica during the Spanish Civil War. It shows the tragedies war inflicts upon individuals, particularly innocent civilians. The work has gained a monumental status, becoming a perpetual reminder of the tra...
31,797
Street Gambler (STRGAMB) Madrid is a tremendously historic and monumental city that attracts several millions of visitors each year. Where there are tourists, there are also artists that entertain the crowds in the streets and gamblers that challenge pedestrians to often snaky games. One of them is just about to ask y...
31,798
Discrete Math Problem (GCD3) Given N, M and K (1 <= N, M <= 100^200 and 1 <= K <= 16) which N = a + b M = a^2 + b^2 - (2^K - 2) * a * b with a > 0, b > 0 and gcd(a, b) = 1. Your task is to find gcd(N, M). Input The input file consists of several data sets. The first line contains the number of data sets T (1 <= T ...
31,799