You are on page 1of 11

Problem A

a.c, a.cpp, a.java


a.in, a.out

You are given a rectangle with n rows and m columns .From the left bottom you draw a
straight to the right top, This straight will cross some squares.Your task is to calculate the
number of these squares

Input Specification

The input contains several test cases. Each test case contains tow integers n and m
representing the sizes of a rectangle.The last test case is followed by two zeros.

Output Specification

For each test case output one line containing the number of squares crossed by the straight as
explained above.

Sample Input

1 1
1 2
3 5
2 4
0 0

Sample Output

1
2
7
4
Problem B
b.c, b.cpp, b.java
b.in, b.out

There are several ancient Greek texts that contain descriptions of the fabled island Atlantis.
Some of these texts even include maps of parts of the island. But unfortunately, these maps
describe different regions of Atlantis. Your friend Bill has to know the total area for which maps
exist. You (unwisely) volunteered to write a program that calculates this quantity.
Input
The input file consists of several test cases. Each test case starts with a line containing a single
integer n (1<=n<= 100) of available maps. The n following lines describe one map each. Each of
these lines contains four numbers x1,y1,x2,y2 (0<=x1< x2 <= 100000, 0<=y1< y2<= 100000),
not necessarily integers. The values (x1, y1) and (x2,y2) are the coordinates of the top-left resp.
bottom-right corner of the mapped area. The input file is terminated by a line containing a single
0. Don’t process it.

Output
For each test case, your program should output one section. The first line of each section must be
“Test case #k”, where k is the number of the test case (starting with 1). The second one must be
“Total explored area: a”, where a is the total explored area (i.e. the area of the union of all
rectangles in this test case), printed exact to two digits to the right of the decimal point.
Output a blank line after each test case.
Sample Input
2
10 10 20 20
15 15 25 25.5
0
Sample Output
Test case #1
Total explored area: 180.00
Problem C
c.c, c.cpp, c.java
c.in, c.out

The Hungarian Paul Vladimir, was not only one of the strangest mathematicians of the 20th
century, he was also among the most famous ones. He kept on publishing widely circulated
papers up to a very high age, and every mathematician having the honor of being a co-author to
Vladimir is well respected.
Not everybody got a chance to co-author a paper with Vladimir, so many people were content if
they managed to publish a paper with somebody who had published a paper with Vladimir. This
gave rise to the so-called Vladimir numbers. An author who has jointly published with Vladimir
had Vladimir number 1. An author who had not published with Vladimir but with somebody
with Vladimir number 1 obtained Vladimir number 2, and so on. Today, nearly everybody wants
to know what Vladimir number he or she has. Your task is to write a program that computes
Vladimir numbers for a given set of scientists.
Input
The input file contains a sequence of scenarios, each scenario consisting of a paper database and
a list of names. A scenario begins with the line “p n”, where p and n are natural numbers with
1<=p<= 32000; 1<=n<= 3000. Following this line are p lines containing descriptions of papers
(this is the paper database). A paper is described by a line of the following form:
LastName1, FirstName1, LastName2, Firstname2, . . . : TitleOfThePaper
The names and the title may contain any ASCII characters between 32 and 126 except commas
and colons. There will always be exactly one space character following each comma. The first
name may be abbreviated, but the same name will always be written in the same way. In
particular, Vladimir’ name is always written as “Vladimir, P.”
Example:
Smith, M.N., Martin, G., Vladimir, P.: Newtonian forms of prime factors matrices.
After the p papers follow n lines each containing exactly one name in the same format as in the
paper database.
The line ‘0 0’ terminates the input.
No name will consist of more than 40 characters. No line in the input file contains more than 250
characters. In each scenario there will be at most 10 000 different authors.
Output
For every scenario first print the number of the scenario in the format shown in the sample
output. Then print for every author name in the list of names their Vladimir number based on the
papers in the paper database of the scenario. The authors should be output in the order given in
the input file. Authors that do not have any relation to Vladimir via the papers have Vladimir
number infinity. Adhere to the format shown in the sample output.

Sample Input
22
Smith, M.N., Martin, G., Vladimir, P.: Newtonian forms of prime factors matrices.
Gardner, M., Martin, G.: Commuting Names
Smith, M.N.
Gardner, M.
00
Sample Output
Database #1
Smith, M.N.: 1
Gardner, M.: 2
Problem D
d.c, d.cpp, d.java
d.in, d.out

This problem is very easy for those interested in geometry. Your are given 3 points A,B and
C(each point is represented by its coordinates (x,y)). Your task is to calculate the area of the
circle containing this 3 points.

Input specifications
The input file,contains several test case,each test case contains 6 real numbers representing the
coordinates of the 3 points A,B and C , XA YA XB YB XC YC. The end of file is detected by 6
zeros (0 0 0 0 0 0).

Output specifications
For each test case,output one line containing the area of the circle as described above,this area
will be a real number with 4 digits after comma (after rounding).

Simple input
1 0 0 1 -1 0
000000

Simple output
3.1416
Problem E
e.c, e.cpp, e.java
e.in, e.out

Ali once was trapped in a cave together with his comrade soldiers surrounded by Romans. All of
Ali 's fellow soldiers preferred not to surrender but to commit suicide. So they all formed a circle
and agreed on a number k. Every k-th person in the circle would then commit suicide. However,
Ali had different priorities and didn't want to die just yet. According to the legend he managed to
find the safe spot in the circle where he would be the last one to commit suicide. He surrendered
to the Romans and became a citizen of Rome a few years later. It is a lesser known fact that the
souls of Ali and his comrades were all born again in modern times. Obviously Ali and his reborn
fellow soldiers wanted to avoid a similar fiasco in the future. Thus they asked a consulting
company to work out a better decision scheme. The company came up with the following
scheme:

• For the sake of tradition all soldiers should stand in a circle. This way a number between
0 and N-1 is assigned to each soldier, where N is the number of soldiers.
• As changing numbers in the old scheme turned out to be horribly inefficient, the number
assigned to a soldier will not change throughout the game.
• The consulting company will provide two numbers a and b which will be used to
calculate the number of the next soldier as follows: Let x be the number of the current
soldier, then the number of the next soldier is the remainder of a·x2 + b mod N.
• We start with the soldier with number 0 and each soldier calculates the number of the
next soldier according to the formula above.
• As everyone deserves a second chance a soldier will commit suicide once his number is
calculated for the second time.
• In the event that the number of a soldier is calculated for the third time the game will end
and all remaining soldiers will surrender.

You are to write a program that given the number of soldiers N and the constants a and b
determines the number of survivors.

Input Specification

The input file consists of several test cases. Each test case consists of a single line containing the
three integers N (2 ≤ N ≤ 109), a and b (0 ≤ a,b < N) separated by white space. You may safely
assume that the first soldier dies after no more than one million (106) steps. The input is
terminated by a single number 0 which should not be processed.

Output Specification

For each test case output a single line containing the number of soldiers that survive.

Sample Input Sample Output

5 1 1 2
10 3 7 4
101 9 2 96
0
Problem F
f.c, f.cpp, f.java
f.in, f.out

You are visiting the Centre Douhimi which contains a lot of modern paintings. In particular you
notice one painting which consists solely of black and white squares, arranged in rows and
columns like in a chess board (no two adjacent squares have the same colour). By the way, the
artist did not use the tool of problem A to create the painting.

Since you are bored, you wonder how many 8 × 8 chess boards are embedded within this
painting. The bottom right corner of a chess board must always be white.

Input Specification

The input contains several test cases. Each test case consists of one line with three integers n, m
and c. (8 ≤ n, m ≤ 40000), where n is the number of rows of the painting, and m is the number of
columns of the painting. c is always 0 or 1, where 0 indicates that the bottom right corner of the
painting is black, and 1 indicates that this corner is white.

The last test case is followed by a line containing three zeros.

Output Specification

For each test case, print the number of chess boards embedded within the given painting.

Sample Input

8 8 0
8 8 1
9 9 1
0 0 0

Sample Output

0
1
2
Problem G
g.c, g.cpp, g.java
g.in, g.out
Simple Input

Simple output
450

2100
Problem H
h.c, h.cpp, h.java
h.in, h.out

Simple Input

Simple output
1

You might also like