Professional Documents
Culture Documents
Problemset Local Apr06
Problemset Local Apr06
From the article Number Theory in the 1994 Microsoft Encarta: "If A, B, C are integers such that A=BC, A is called a multiple of B or of C, and B or C is called a divisor or factor of A. If C is not 1, B is called a proper divisor of A. Even integers, which include 0, are multiples of 2, for example, -4, 0, 2, 10; an odd integer is an integer that is not even, for example, -5, 1, 3, 9. A perfect number is a positive integer that is equal to the sum of all its positive, proper divisors; for example, 6, which equals 1 + 2 + 3, and 28, which equals 1 + 2 + 4 + 7 + 14, are perfect numbers. A positive number that is not perfect is imperfect and is deficient or abundant according to whether the sum of its positive, proper divisors is smaller or larger than the number itself. Thus, 9, with proper divisors 1, 3, is deficient; 12, with proper divisors 1, 2, 3, 4, 6, is abundant." Problem Statement: Given a number, determine if it is perfect, abundant, or deficient. Input A list of n positive integers (none greater than 60,000), with 1 < n < 100. A 0 will mark the end of the list. Sample Input 15 28 6 56 60000 22 496 0 Output for Sample Input 15 deficient 28 perfect 6 perfect 56 abundant 60000 abundant 22 deficient 496 perfect
0 0 0 0 3
4 7 7 2 4
Output There should be N+2 lines of output. The first line of output should read INTERSECTING LINES OUTPUT. There will then be one line of output for each pair of planar lines represented by a line of input, describing how the lines intersect: none, line, or point. If the intersection is a point then your program should output the x and y coordinates of the point, correct to two decimal places. The final line of output should read "END OF OUTPUT". Output for Sample Input INTERSECTING LINES OUTPUT point 2.00 2.00 none line point 2.00 5.00 point 1.07 2.20 END OF OUTPUT
Problem 4: Jelly
A local school provides jelly for their pupils every day, and the school staff are very careful to see that each child has exactly the same amount. The jelly is prepared the previous day; the liquid jelly is poured into rectangular sided moulds, one mould per child, and then put in the fridge where it sets. The moulds may differ by the length and width of their sides but are filled to different heights so that they all have the same volume; length, width, and height are always integer numbers. Unfortunately, one of the cleaners loves practical jokes! Whenever he can, before the jelly has set, he tips liquid jelly from one of the moulds into another. He is happy if he succeeds just once and doesnt repeat the joke with other moulds. Your task is to help the school staff by preparing a report for them. They need to know who has lost jelly and who has gained it so that they can correct matters before the children arrive. Input The input consists of one or more scenarios. Each scenario begins with a single integer n, 1 n 100, representing the number of children for whom jelly was prepared. Following this are n lines, each line representing one child. The data for a child consists of the childs name and 3 integer numbers in the range 1 to 100, respectively representing the length, width and height of the jelly in that childs mould, all separated by single spaces. A childs name consists of a sequence of 1 up to 10 letters (upper and/or lower case), and no two children have the same name. A single 0 on a line by itself marks the end of input. Sample Input 3 Joe 10 10 2 Susan 10 5 4 Bill 5 5 8 4 Zoe 10 2 2 Lee 6 5 2 Alan 5 4 4 Tommy 12 5 1 0 Output Your report consists of one line of text per scenario. If the cleaner did not manage to transfer any jelly before it set, you report must say: No child has lost jelly; if the cleaner did manage to transfer jelly, your report must be of the form: ChildA has lost jelly to ChildB, where ChildA is the actual name of the child that has lost jelly and ChildB is the actual name of the child that has gained jelly. Output for Sample Input No child has lost jelly Zoe has lost jelly to Alan
1 4 2 3 2
3 4 2 4 13
23 31 000
Output Print one line for each input set, giving the minimum time that Bonds needs to capture the terrorist, if this is possible (thus print 0 if Bond starts at the terrorist node). Otherwise print 0. Output for the Sample Input 8 0
Assume that Theseus is in cavern C when he hears the Minotaur approaching from A, and that for this scenario, the value of k is 3. He lights a candle and gives chase, pursuing it through A, B, D (leaves a candle), G, E, F (another candle), H, E, G (another), H, E (trapped). Write a program that will simulate Theseus's pursuit of the Minotaur. The description of a labyrinth will identify each cavern by an upper case character and will list the caverns reachable from that cavern in the order that the Minotaur will attempt them, followed by the identifiers for the caverns which the Minotaur and Theseus were in when contact was first made, followed by the value of k. Write a program that will simulate Theseus' pursuit of the Minotaur. Input Input will consist of a series of labyrinths. Each labyrinth will contain a series of cavern descriptors, one per line. Each line will contain a cavern identifier (a single upper case character) followed by a colon (:) and a list of caverns reachable from it (in counterclockwise order). No cavern will be connected to itself. The cavern descriptors will not be ordered in any way. The description of a labyrinth will be terminated by a line starting with a @ character, followed by two pairs of cavern identifiers. The first pair indicates the passage in which Theseus starts, and the second in which the Minotaur starts. The travel in a starting passage is toward the cavern whose identifier is the second character in the pair.
Theseus and Minotaur will never start in the same corridor. The file will be terminated by a line consisting of a single #. A final encounter is possible for each input data set. Sample Input A:BCD D:BACG F:HE G:HED B:AD E:FGH H:FEG C:AD @ACFH A:BCD D:BACG F:HE G:HED B:AD E:FGH H:FEG C:AD @ACDG # Output Output will consist of one line for each labyrinth. Each line will specify who gets killed and where. Note that if the final encounter takes place in a passage it should be specified from Theseus' point of view. Follow the format shown in the example below exactly, which describes the situations referred to above. Output for the Sample Input Theseus is killed between D and G The Minotaur is slain in H