Sunteți pe pagina 1din 12

ICPC-2008 Primer Entrenamiento

Departamento Informtica - Sistemas a April 5,2008


1

FCyT-UMSS

CIPUMSS Rules
1. All questions require you to read the test data from le input and write results to standard output. Additional input and output specications can be found in the exercise description. 2. All programs will be re-compiled prior to testing with the judges data. 3. Non-standard libraries cannot be used in your solutions. 4. Programming style is not considered in this contest. You are free to code in whatever style you prefer. Documentation is not required. 5. All communication with the judges will be handled by the PC 2 environment. 6. The allowed programming languages are C, C++ and Java. 7. Judgesdecisions are to be considered nal. No cheating will be tolerated. 8. There are seven questions to be completed in four hours(real ICPC: eight to ten questions to be completed in ve hours). These rule are in concordance with the contest rules as showed in: http://icpc.baylor.edu/icpc/Regionals/About.htm.

ICPC 2008-Primer Entrenamiento

Problem A : Savings Account

Problem A : Savings Account


input: standard input output: standard output

Description
Suppose you open a savings account with a certain initial balance. You will not make any withdrawals or further deposits for a number of years. The bank will compound your balance (add the annual interest) once a year, on the anniversary of the opening of the account. Your goal is to achieve a certain target amount in your savings account. In how may years will the target amount be achieved? The input le will contain data for one or more test cases, one test case per line. Each line will contain three numbers: the initial balance, the annual interest rate (as a percentage of the balance), and the target amount, separated by blank spaces. These will be positive numbers; they may or may not contain a decimal point. The target amount will be greater than the initial balance. The input is terminated by end-of-le

Output
For each line of input, your program will produce exactly one line of output: This line will contain one positive integer value: the number of years required to achieve the target amount.

Example
Input 200.00 6.5 300 500 4 1000.00 Output 7 18

ICPC 2008-Primer Entrenamiento

Problem B : Baskets of Gold Coins

Problem B : Baskets of Gold Coins


input: standard input output: standard output

Description
You are given N baskets of gold coins. The baskets are numbered from 1 to N . In all except one of the baskets, each gold coin weighs w grams. In the one exceptional basket, each gold coin weighs w d grams. A wizard appears on the scene and takes 1 coin from Basket 1, 2 coins from Basket 2, and so on, up to and including N 1 coins from Basket N 1. He does not take any coins from Basket N . He weighs the selected coins and concludes which of the N baskets contains the lighter coins. Your mission is to emulate the wizards computation. The input le will consist of one or more lines; each line will contain data for one instance of the problem. More specically, each line will contain four positive integers, separated by one blank space. The rst three integers are, respectively, the numbers N , w, and d, as described above. The fourth integer is the result of weighing the selected coins. N will be at least 2 and not more than 8000. The value of w will be at most 30. The value of d will be less than w.

Output
For each instance of the problem, your program will produce one line of output, consisting of one positive integer: the number of the basket that contains lighter coins than the other baskets.

Example
Input 10 25 8 1109 10 25 8 1045 8000 30 12 959879400 Output 2 10 50

ICPC 2008-Primer Entrenamiento

Problem C : Doors and Penguins

Problem C : Doors and Penguins


input: standard input output: standard output

Description
The organizers of the Annual Computing Meeting have invited a number of vendors to set up booths in a large exhibition hall during the meeting to showcase their latest products. As the vendors set up their booths at their assigned locations, they discovered that the organizers did not take into account an important facteach vendor supports either the Doors operating system or the Penguin operating system, but not both. A vendor supporting one operating system does not want a booth next to one supporting another operating system. Unfortunately the booths have already been assigned and even set up. There is no time to reassign the booths or have them moved. To make matter worse, these vendors in fact do not even want to be in the same room with vendors supporting a different operating system. Luckily, the organizers found some portable partition screens to build a wall that can separate the two groups of vendors. They have enough material to build a wall of any length. The screens can only be used to build a straight wall. The organizers need your help to determine if it is possible to separate the two groups of vendors by a single straight wall built from the portable screens. The wall built must not touch any vendor booth (but it may be arbitrarily close to touching a booth). This will hopefully prevent one of the vendors from knocking the wall over accidentally. The input consists of a number of cases. Each case starts with 2 integers on a line separated by a single space: D and P , the number of vendors supporting the Doors and Penguins operating system, respectively (1 D, P 500). The next D lines specify the locations of the vendors supporting Doors. This is followed by P lines specifying the locations of the vendors supporting Penguins. The location of each vendor is specied by four positive integers: x1, y1, x2, y2. (x1, y1) species the coordinates of the southwest corner of the booth while (x2, y2) species the coordinates of the northeast corner. The coordinates satisfy x1 < x2 and y1 < y2. All booths are rectangular and have sides parallel to one of the compass directions. The coordinates of the southwest corner of the exhibition hall is (0, 0) and the coordinates of the northeast corner is (15000, 15000). You may assume that all vendor booths are completely inside the exhibition hall and do not touch the walls of the hall. The booths do not overlap or touch each other. The end of input is indicated by D = P = 0. Output For each case, print the case number (starting from 1), followed by a colon and a space. Next, print the sentence: It is possible to separate the two groups of vendors.

ICPC 2008-Primer Entrenamiento

Problem C : Doors and Penguins

if it is possible to do so. Otherwise, print the sentence: It is not possible to separate the two groups of vendors. Print a blank line between consecutive cases.

Example
Input 33 10 40 20 50 80 60 30 60 40 30 30 40 50 50 60 10 10 20 21 10 10 20 40 10 50 25 12 35 00 Output Case 1: It is possible to separate the two groups of vendors. Case 2: It is not possible to separate the two groups of vendors.

50 90 70 40 60 20 20 20 40

ICPC 2008-Primer Entrenamiento

Problem D : GPA

Problem D : GPA
input: standard input output: standard output

Description
Each course grade is one of the following ve letters: A, B, C, D, and F . (Note that there is no grade E.) The grade A indicates superior achievement, whereas F stands for failure. In order to calculate the GPA, the letter grades A, B, C, D, and F are assigned the following grade points, respectively: 4, 3, 2, 1, and 0. The input le will contain data for one or more test cases, one test case per line. On each line there will be one or more upper case letters, separated by blank spaces.

Output
Each line of input will result in exactly one line of output. If all upper case letters on a particular line of input came from the set {A, B, C, D, F } then the output will consist of the GPA, displayed with a precision of two decimal places. Otherwise, the message Unknown letter grade in input" will be printed.

Example
Input ABCDF BFFCCA DCEF Output 2.00 1.83 Unknown letter grade in input

ICPC 2008-Primer Entrenamiento

Problem E : Knots

Problem E : Knots
input: standard output output: standard output

Description
An even number N of strands are stuck through a wall. On one side of the wall, a girl ties N/2 knots between disjoint pairs of strands. On the other side of the wall, the girls groom-to-be also ties N/2 knots between disjoint pairs of strands. You are to nd the probability that the knotted strands form one big loop (in which case the couple will be allowed to marry). For example, suppose that N = 4 and you number the strands 1, 2, 3, 4. Also suppose that the girl has created the following pairs of strands by tying knots: {(1, 4), (2, 3)}. Then the groom?to?be has two choices for tying the knots on his side: {(1, 2), (3, 4)} or {(1, 3), (2, 4)}. The input le consists of one or more lines. Each line of the input le contains a positive even integer, less than or equal to 100. This integer represents the number of strands in the wall.

Output
For each line of input, the program will produce exactly one line of output: the probability that the knotted strands form one big loop, given the number of strands on the corresponding line of input. Print the probability to 5 decimal places.

Example
Input 4 20 Output 0.66667 0.28377

ICPC 2008-Primer Entrenamiento

Problem F : Permutation

Problem F : Permutation
input: standard input output: standard output

Description
Professor Permula gave a number of permutations of the n integers 1, 2, ..., n to her students. For each integer i (1 i n), she asks the students to write down the number of integers greater than i that appears before i in the given permutation. This number is denoted ai. For example, if n = 8 and the permutation is 2, 7, 3, 5, 4, 1, 8, 6, then a1 = 5 because there are 5 numbers (2, 7, 3, 5, 4) greater than 1 appearing before it. Similarly, a4 = 2 because there are 2 numbers (7, 5) greater than 4 appearing before it. John, one of the students in the class, is studying for the nal exams now. He found out that he has lost the assignment questions. He only has the answers (the ais) but not the original permutation. Can you help him determine the original permutation, so he can review how to obtain the answers? The input consists of a number of test cases. Each test case starts with a line containing the integer n (n 500). The next n lines give the values of a1 , ..., an . The input ends with n = 0.

Output
For each test case, print a line specifying the original permutation. Adjacent elements of a permutation should be separated by a comma. Note that some cases may require you to print lines containing more than 80 characters.

ICPC 2008-Primer Entrenamiento

Problem F : Permutation

Example
Input 8 5 0 1 2 1 2 0 0 10 9 8 7 6 5 4 3 2 1 0 0 Output 2,7,3,5,4,1,8,6 10,9,8,7,6,5,4,3,2,1

ICPC 2008-Primer Entrenamiento

Problem G : Tic-Tac-Toe

Problem G : Tic-Tac-Toe
input: standard input output: standard output

Description
4 4 tic-tac-toe is played on a board with four rows (numbered 0 to 3 from top to bottom) and four columns (numbered 0 to 3 from left to right). There are two players, x and o, who move alternately with x always going rst. The game is won by the rst player to get four of his or her pieces on the same row, column, or diagonal. If the board is full and neither player has won then the game is a draw. Assuming that it is xs turn to move, x is said to have a forced win if x can make a move such that no matter what moves o makes for the rest of the game, x can win. This does not necessarily mean that x will win on the very next move, although that is a possibility. It means that x has a winning strategy that will guarantee an eventual victory regardless of what o does. Your job is to write a program that, given a partially-completed game with x to move next, will determine whether x has a forced win. You can assume that each player has made at least two moves, that the game has not already been won by either player, and that the board is not full. The input le contains one or more test cases, followed by a line beginning with a dollar sign that signals the end of the le. Each test case begins with a line containing a question mark and is followed by four lines representing the board; formatting is exactly as shown in the example. The characters used in a board description are the period (representing an empty space), lowercase x, and lowercase o. For this problem, the rst forced win is determined by board position, not the number of moves required for victory. Search for a forced win by examining positions (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), ...,(3, 2), (3, 3), in that order, and output the rst forced win you nd. In the second test case below, note that x could win immediately by playing at (0, 3) or (2, 0), but playing at (0, 1) will still ensure victory (although it unnecessarily delays it), and position (0, 1) comes rst.

Output
For each test case, output a line containing the (row, column) position of the rst forced win for x, or ##### if there is no forced win. Format the output exactly as shown in the example.

10

ICPC 2008-Primer Entrenamiento

Problem G : Tic-Tac-Toe

Example
Input ? .... .xo. .ox. .... ? o... .ox. .xxx xooo $ Output ##### (0,1)

11

S-ar putea să vă placă și