Sample Input

advertisement
10136
Problem E - Chocolate Chip Cookies
Making chocolate chip cookies involves mixing flour, salt, oil, baking soda and chocolate
chips to form dough which is rolled into a plane about 50 cm square. Circles are cut from
the plane, placed on a cookie sheet, and baked in an oven for about twenty minutes. When
the cookies are done, they are removed from the oven and allowed to cool before being
eaten.
We are concerned here with the process of cutting the first cookie after the dough has been
rolled. Each chip is visible in the planar dough, so we need simply to place the cutter so as
to maximize the number of chocolate chips contained in its perimeter.
Input
The input begins with a single positive integer on a line by itself indicating the number of
the cases following, each of them as described below. This line is followed by a blank line,
and there is also a blank line between two consecutive inputs.
Standard input consists of a number of lines, each containing two floating point numbers
indicating the (x,y) coordinates of a chip in the square surface of cookie dough. Each
coordinate is between 0.0 and 50.0 (cm). Each chip may be considered a point (i.e. these
are not President's Choice Cookies). Each chip is at a different position. There are at most
200 chocolate chips.
Output
For each test case, the output must follow the description below. The outputs of two
consecutive cases will be separated by a blank line.
Standard output consists of a single integer: the number of chocolate chips that can be
contained in a single cookie whose diameter is 5 cm. The cookie need not be fully
contained in the 50 cm square dough (i.e. it may have a flat side).
Sample Input
1
4.0
4.0
5.0
1.0
1.0
1.0
1.0
4.0
5.0
6.0
20.0
21.0
22.0
25.0
1.0 26.0
Output for Sample Input
4
In general, the algorithm works like this:
for each pair p1 and p2 of the chips do
find a circle of radius 2.5cm that touches the two points;
find the number of chips inside that circles;
update the current max if that number is larger.
od
So the problem is how to find out a circle that touches two points.
10167
Problem G. Birthday Cake
Background
Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for
them.Now we put the cake onto a Descartes coordinate. Its center is at (0,0), and the cake's
length of radius is 100.
There are 2N (N is a integer, 1<=N<=50) cherries on the cake. Mother wants to cut the
cake into two halves with a knife (of course a beeline). The twins would like to be treated
fairly, that means, the shape of the two halves must be the same (that means the beeline
must go through the center of the cake) , and each half must have N cherrie(s). Can you
help her?
Note: the coordinate of a cherry (x , y) are two integers. You must give the line as form
two integers A,B(stands for Ax+By=0), each number in the range [-500,500]. Cherries are
not allowed lying on the beeline. For each dataset there is at least one solution.
Input
The input file contains several scenarios. Each of them consists of 2 parts: The first part
consists of a line with a number N, the second part consists of 2N lines, each line has two
number, meaning (x,y) .There is only one space between two border numbers. The input
file is ended with N=0.
Output
For each scenario, print a line containing two numbers A and B. There should be a space
between them. If there are many solutions, you can only print one of them.
Sample Input
2
-20 20
-30 20
-10 -50
10 -5
0
Sample Output
0 1
One obvious way is to sort all the cherries about the angle of the polor
coordinates. Then, place the cuts at the intervals between the cherry.
Unfornately, the biggest problem is that we need integral solution. Even
if we know where to place the cut, it would be difficult to find an integral
solution. Therefore, we use the random method to do it. We generate the
required values of A and B randomly and check if they divides the cherries
into two. The process repeats until a solution is found.
10215
Problem I
The Largest/Smallest Box...
Input: Standard Input
Output: Standard Output
Time Limit: 2 seconds
In the following figure you can see a rectangular card. The width of the card is W and
length of the card is L and thickness is zero. Four (x*x) squares are cut from the four
corners of the card shown by the black dotted lines. Then the card is folded along the
magenta lines to make a box without a cover.
Fig: Cutting & Folding the Card.
Given the width and height of the box, you will have to find the value of x for which the
box has maximum and minimum volume.
Input
The input file contains several lines of input. Each line contains two positive
floating-point numbers L(0<L<10000)and W(0<W<10000); which indicate the length
and width of the card respectively.
Output
For each line of input you should give one line of output, which should contain two
or more floating-point numbers separated by a single space. The floating-point
numbers should contain three digits after the decimal point. The first floating point
number indicates the value for which the volume of the box is maximum and then
the next values (sorted in ascending order) indicate the values for which the volume
of the box is minimum.
Sample Input:
1 1
2 2
3 3
Sample Output:
0.167 0.000 0.500
0.333 0.000 1.000
0.500 0.000 1.500
Let the width and length of the paper be W and L respectively.
The volumn of the box:
v = x(L − 2x)(W − 2x) = 4x 3 − 2(L + W)x 2 + LWx
In order to find out the maximum volumn, we need to differentiate the above
expression respect to x. So we have:
dv
= 12x 2 − 4(L + W)x + LW
dx
This is a quadratic equation and we can solve for x. The larger root correspond to
the zero volumn case so the smaller root is the answer. If L>W, then the root x=L/2
then one of the dimension of the box is negative and there the root cannot be x=L/2,
so the root is 0, W/2. On the other hand, if L<W, then the root should be 0, L/2.
For minimum volumn, v=0 which correspond to x=0, L/2 and W/2.
Problem C
Is This Integration ?
Input: Standard Input
Output: Standard Output
Time Limit: 3 seconds
In the image below you can see a square ABCD, where AB = BC = CD = DA = a. Four
arcs are drawn taking the four vertexes A, B, C, D as centers and a as the radius. The
arc that is drawn taking A as center, starts at neighboring vertex Band ends at
neighboring vertex D. All other arcs are drawn in a similar fashion. Regions of three
different shapes are created in this fashion. You will have to determine the total area if
these different shaped regions.
Input
The input file contains a floating-point number a (a>=0 a<=10000) in each line which
indicates the length of one side of the square. Input is terminated by end of file.
Output
For each line of input, output in a single line the total area of the three types of region
(filled with different patterns in the image above). These three numbers will of course
be floating point numbers with three digits after the decimal point. First number will
denote the area of the striped region, the second number will denote the total area of the
dotted regions and the third number will denote the area of the rest of the regions.
Sample Input:
0.1
0.2
0.3
Sample Output:
0.003 0.005 0.002
0.013 0.020 0.007
0.028 0.046 0.016
Download