0% found this document useful (0 votes)
278 views17 pages

ECPC 2017 - Final Round

Jfh

Uploaded by

yassine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
278 views17 pages

ECPC 2017 - Final Round

Jfh

Uploaded by

yassine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
— Ecrc 2017 ACM International Collegiate Pro Contest EGYPTIAN COLLEGIATE ieee PROGRAMMING CONTEST 42> Academy for November, 4° 2017 The ACM International Collegiate Programming Contest Sponsored by ICPC Foundation ACM ACPC ARAB COLLEGIATE PROGRAMMING CONTEST The Egyptian Collegiate Programming Contest (Contest Problems) oS Arab Academy for Science, Technology & Maritime Transport Alexandria, Egypt November, 2017 ‘ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest ‘Arab Academy for Science, Technology and Maritime Transport, 2017 Problem A. Assessments Input file: assosenent. in Output file standard output Balloon Color: Yellow ‘As the World Cup approaches, FIFA is holding a worldwide assessment of players. In each assessment, wwe have a line of NV distinct players, the players are standing in the order 0, 1,--- , N — 1. The assessment, is carried out in k rounds, in each round the players run for a long time. When they finish the round, it, sometimes happens (with probability p) that exactly one pair of adjacent players end up swapping their positions; this pair of adjacent players occurs randomly with equal chance. FIFA wants your help finding ut the probability that the final state after the k rounds will have the players « and y swapped. Input ‘The first line of the input contains a single integer 1 N. Output For each test case output a single line displaying the case number and the area of the cheerers rounded to exactly 5 decimal places. The output will be checked with a relative error. Example glorious. in Tandard output z tase Ty aie. B7EE2 3103 Case 2: 287.52220 2104 ase 3: 31096,29444 5 1006 Note « inccircle is the largest circle the will fit inside a polygon that touches every side. « citcumeircle is the circle that passes through each vertex of the regular polygon. ‘ The given figure is a demonstration of the first test case, where the radius of the smallest circle is the given R, and the answer is the area of the grey parts. ‘© The formula P\\ C denotes the area covered in P and not covered in C, as shown in the figure. Page 10 of 16 ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest ‘Arab Academy for Science, Technology and Maritime Transport, 2017 Problem H. Half Nice Years Input file: halinice.in Output file: standard output Balloon Color: Black Salah is really optimistic about the qualification of the Egyptian football team for the world cup 2018 ‘He was thinking deeply about why it didn’t happen often that the Egyptian team qualified to the world ccup, 80 he decided to call 2018 a half-nice year. He comes up with the hypothesis that the Egyptian team will always qualify to the world cup only if itis held in a half-nice year. In order to test his hypothesis we need to find the largest half-nice number in a given range [4, B]. He says a given number X is half-nice if its decimal representation can be divided into two non-zero halves(of the same length) and the two halves have a non-trivial common divisor (there's a number d > 1 that divides both parts). In case number X have odd number of digits (2r+1), them the first half will have the first r digits in the decimal representation of X (from the left), and the second half will contain the remaining r + 1 digits in the decimal representation of X. Input ‘The first line of the input consists of a single integer 1 < T < 10° the number of test cases. Each test case consists of one line containing 2 space separated integers A, B, where 10 < A < B < 10" Output For each test case output a single line displaying the case number, then followed by either a single integer X, which is the largest half-nice number in the range [A, B] or ‘impossible’ if there are no such numbers. Example halfnice in standard output z Gaze ii impossible 20 21 Case 2: 2018 10 2019 Case 3: 4005 4000 4006 Note + The number 20122 is a half-nice number (hopefully the Egyptian team qualifies that year), because it’s two halves 20 and 122 have a non-trivial common divisor which is 2. © The number 2000 is not a half-nice number because the second hall is zero. ‘In the third, test case 4005 is half-nice because 40 and 5 share the non-trivial common divisor 5. It is allowed for the second half to have trailing zeros. Page 11 of 16 ‘ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest Arab Academy for Science, Technology and Maritime Transport, 2017 Problem |. Important matches Input file: important. in Output file: standard output Balloon Color. Light blue In the qualification rounds of the World Cup, there were two disjoint sets of teams 5; = [1,-+-,N] and ‘S) = [1,---,M]. Given a matrix X that decides the importance of the match between team i € Si against team j € Sz by the value X;3. S1 represents the rows of the matrix X, and S represents the columns of the matrix X. We would like to answer Q queries, where each decides the importance of all ‘the matches played by all the teams from the subgroup [4,--- ,C] from $ against all teams from the subgroup [B,-++ ,D] from Sp, such that 1 < A << N,1 (a2 — 20)f(e1) is satisfied, or also equivalently Af (zi) + (1 — A) f (2) > F(Am1 + (1 — A)zr2) is satisfied for 0 < A <1. # If P and Q are convex functions, then P +@ is also convex, where (P + Q)/ P(x) + Qa). Page 14 of 16 ‘ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest ‘Arab Academy for Science, Technology and Maritime Transport, 2017 Problem K. Katryoshka Input file: katryoshka.in Output file: standard output Balloon Color: White ‘The Egyptian football team will be in Russia for the World Cup, of course they all would like to buy souvenirs for their families. Luckily they met the king of souvenirs of the famous Russian souvenir ‘Matryoshkaj the king makes his masterpiece Katryoshka using different kinds of pieces: wooden eyes, ‘wooden mouths, and wooden bodies. He can form a nice Katryoshka using one of the following, ways: # Two eyes and a body. ‘+ Two eyes, mouth and a body. ‘ Bye, mouth and a body. If the king has n eyes, m mouths and & bodies, what is the largest number of Katryoshkas that can be made by the king? Input ‘The first line of the input contains a single integer 1 < T < 100 the number of test cases. Each test case consists of a single line containing 3 space separated integers ‘n m k’ the number of eyes, mouths and bodies respectively; where 0 < n,m,k < 108, Output For each test case output a line displaying the case number and a, single integer which is the largest number of nice Katryoshka pieces, Example Tatryestia. ia Tanard oatpat A Case tr 123 Case 2: 0 0112 Case 3: 14 14 2t 23 Case 4: 57 90 24 89 Page 15 of 16 ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest ‘Arab Academy for Science, Technology and Maritime Transport, 2017 Problem L. Lazy ERCD Input file: lazy.in Output file: standard output Balloon Color: Red FIFA changed the style of the World Cup. There are no group rounds anymore, therefore the World Cup will be a pure knockout competition. In a knockout competition, each match that is played between two teams, the losing team is knocked-out of the competition and will not play again, until there's exactly one winner (we are not concerned about other positions, only the first place). Having N teams in the World Cup, our ERCD wants to know how many matches he needs to watch (he ‘will really watch all matches). He is lazy to count that number, so he needs you to write a program that, calculates it Input ‘The first line of the input contains a single integer 1

You might also like