| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 4031 | Grey Area |
|
| 4032 | Expected Allowance |
|
| 4033 | Stopped Watches |
|
| 4034 | Digits on the Floor |
|
| 4035 | Spherical Mirrors |
|
| 4036 | Traveling Cube |
|
Description
Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator.

Figure 1 is an example of histogram automatically produced by his histogram generator. A histogram is a visual display of frequencies of value occurrences as bars. In this example, values in the interval 0-9 occur five times, those in the interval 10-19 occur three times, and 20-29 and 30-39 once each.
Dr. Grey's histogram generator is a simple tool. First, the height of the histogram is fixed, that is, the height of the highest bar is always the same and those of the others are automatically adjusted proportionately. Second, the widths of bars are also fixed. It can only produce a histogram of uniform intervals, that is, each interval of a histogram should have the same width (10 in the above example). Finally, the bar for each interval is painted in a grey color, where the colors of the leftmost and the rightmost intervals are black and white, respectively, and the darkness of bars monotonically decreases at the same rate from left to right. For instance, in Figure 1, the darkness levels of the four bars are 1, 2/3, 1/3, and 0, respectively.
In this problem, you are requested to estimate ink consumption when printing a histogram on paper. The amount of ink necessary to draw a bar is proportional to both its area and darkness.
Input
The input consists of multiple datasets, each of which contains integers and specifies a value table and intervals for the histogram generator, in the following format.
n w
v1
v1
.
.
vn
n
w
v < w
v < 2w
You may assume the following.
| 1 |
|
| 10 |
|
| 0 |
for 1 |
You can also assume that the maximum value is no less than w
Output
For each dataset, output a line containing the amount of ink consumed in printing the histogram. One unit of ink is necessary to paint one highest bar black. Assume that 0.01 units of ink per histogram is consumed for various purposes except for painting bars such as drawing lines and characters (see Figure 1). For instance, the amount of ink consumed in printing the histogram in Figure 1 is:
| 1×1 + |
|
| = |
1 + |
| = |
1.47666... |
Each output value should be in a decimal fraction and may have an error less than 10-5
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n
In this problem, you are asked to write a program that finds the expected value of the number of given bills.
For example, when n = 2
+
+
,
,
,
,
,
,
,
+
+
)×1 +
×2 +
×3 +
×4 +
×5 +
×6 +
×7 +
×8 +
×9
Input
The input is a sequence of lines each of which contains three integers n
| 1 |
| 2 |
| 0 |
| nm×mn < 100000000(108) |
The end of the input is indicated by a line containing three zeros.
Output
The output should be comprised of lines each of which contains a single decimal fraction. It is the expected number of bills and may have an error less than 10-7
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In the middle of Tyrrhenian Sea, there is a small volcanic island called Chronus. The island is now uninhabited but it used to be a civilized island. Some historical records imply that the island was annihilated by an eruption of a volcano about 800 years ago and that most of the people in the island were killed by pyroclastic flows caused by the volcanic activity. In 2003, a European team of archaeologists launched an excavation project in Chronus Island. Since then, the project has provided many significant historic insights. In particular the discovery made in the summer of 2008 astonished the world: the project team excavated several mechanical watches worn by the victims of the disaster. This indicates that people in Chronus Island had such a highly advanced manufacturing technology.
Shortly after the excavation of the watches, archaeologists in the team tried to identify what time of the day the disaster happened, but it was not successful due to several diffculties. First, the extraordinary heat of pyroclastic flows severely damaged the watches and took away the letters and numbers printed on them. Second, every watch has a perfect round form and one cannot tell where the top of the watch is. Lastly, though every watch has three hands, they have a completely identical look and therefore one cannot tell which is the hour, the minute, or the second (It is a mystery how the people in Chronus Island were distinguishing the three hands. Some archaeologists guess that the hands might be painted with different colors, but this is only a hypothesis, as the paint was lost by the heat). This means that we cannot decide the time indicated by a watch uniquely; there can be a number of candidates. We have to consider different rotations of the watch. Furthermore, since there are several possible interpretations of hands, we have also to consider all the permutations of hands.
You are an information archaeologist invited to the project team and are asked to induce the most plausible time interval within which the disaster happened, from the set of excavated watches.
In what follows, we express a time modulo 12 hours. We write a time by the notation hh : mm : ss
The watches in Chronus Island obey the following conventions of modern analog watches.
- A watch has three hands, i.e. the hour hand, the minute hand, and the second hand, though they look identical as mentioned above.
- Every hand ticks 6 degrees clockwise in a discrete manner. That is, no hand stays between ticks, and each hand returns to the same position every 60 ticks.
- The second hand ticks every second.
- The minute hand ticks every 60 seconds.
- The hour hand ticks every 12 minutes.
At the time 00:00:00, all the three hands are located at the same position.
Because people in Chronus Island were reasonably keen to keep their watches correct and pyroclastic flows spread over the island quite rapidly, it can be assumed that all the watches were stopped in a short interval of time. Therefore it is highly expected that the time the disaster happened is in the shortest time interval within which all the excavated watches have at least one candidate time.
You must calculate the shortest time interval and report it to the project team.
Input
The input consists of multiple datasets, each of which is formatted as follows.
n
s1 t1 v1
s2 t2 v2
...
sn tn vn
The first line contains a single integer n
n
10)
si, ti, ui
59
Note that the positions of the hands of a watch can be expressed in many different ways. For example, if a watch was stopped at the time 11:55:03, the positions of hands can be expressed differently by rotating the watch arbitrarily (e.g. 59 55 3, 0 56 4, 1 57 5, etc.) and as well by permuting the hour, minute, and second hands arbitrarily (e.g. 55 59 3, 55 3 59, 3 55 59, etc.).
The end of the input is indicated by a line containing a single zero.
Output
For each dataset, output the shortest time interval within which all the watches given in the dataset have at least one candidate time. The output must be written in a single line in the following format for each dataset.
hh
mm
ss
h'h'
m'm'
s's'
Each line contains a pair of times hh
mm
ss
m'm'
s's'
mm
ss
m'm'
s's'
In calculating the shortest interval, you can exploit the facts that every watch has at least one candidate time and that the shortest time interval contains 00:00:00 only if the interval starts from 00:00:00 (i.e. the shortest interval terminates before the time reverts to 00:00:00).
If there is more than one time interval that gives the shortest, output the one that first comes after 00:00:00 inclusive.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Taro attempts to tell digits to Hanako by putting straight bars on the floor. Taro wants to express each digit by making one of the forms shown in Figure 2.
Since Taro may not have bars of desired lengths, Taro cannot always make forms exactly as shown in Figure 2. Fortunately, Hanako can recognize a form as a digit if the connection relation between bars in the form is kept. Neither the lengths of bars nor the directions of forms affect Hanako's perception as long as the connection relation remains the same. For example, Hanako can recognize all the awkward forms in Figure 3 as digits. On the other hand, Hanako cannot recognize the forms in Figure 4 as digits. For clarity, touching bars are slightly separated in Figures 2, 3 and 4. Actually, touching bars overlap exactly at one single point.


In the forms, when a bar touches another, the touching point is an end of at least one of them. That is, bars never cross. In addition, the angle of such two bars is always a right angle.
To enable Taro to represent forms with his limited set of bars, positions and lengths of bars can be changed as far as the connection relations are kept. Also, forms can be rotated.
Keeping the connection relations means the following.

- Separated bars are not made to touch.
- Touching bars are not made separate.
- When one end of a bar touches another bar, that end still touches the same bar. When it touches a midpoint of the other bar, it remains to touch a midpoint of the same bar on the same side.
- The angle of touching two bars is kept to be the same right angle (90 degrees and -90 degrees are considered different, and forms for 2 and 5 are kept distinguished).
Your task is to find how many times each digit appears on the floor. The forms of some digits always contain the forms of other digits. For example, a form for 9 always contains four forms for 1, one form for 4, and two overlapping forms for 7. In this problem, ignore the forms contained in another form and count only the digit of the ``largest" form composed of all mutually connecting bars. If there is one form for 9, it should be interpreted as one appearance of 9 and no appearance of 1, 4, or 7.
Input
The input consists of a number of datasets. Each dataset is formatted as follows.
| n |
|||
| x1a |
y1a |
x1b |
y1b |
| x2a |
y2a |
x2b |
y2b |
| xna |
yna |
xnb |
xnb |
In the first line, n
The end of the input is indicated by a line containing one zero.

You can also assume the following conditions.
- More than two bars do not overlap at one point.
- Every bar is used as a part of a digit. Non-digit forms do not exist on the floor.
- A bar that makes up one digit does not touch nor cross any bar that makes up another digit.
- There is no bar whose length is zero.
Output
For each dataset, output a single line containing ten integers delimited by single spaces. These integers represent how many times 0, 1, 2,...
Sample Input Download
Sample Output Download
Tags
Discuss
Description
A long time ago in a galaxy, far, far away, there were N spheres with various radii. Spheres were mirrors, that is, they had reflective surfaces ...
You are standing at the origin of the galaxy (0, 0, 0), and emit a laser ray to the direction (u, v, w)
When the laser ray from I
IQN =
NQR

After it is reflected several times, finally it goes beyond our observation. Your mission is to write a program that identifies the last reflection point.
Input
The input consists of multiple datasets, each in the following format.
| N |
|||
| u |
v |
w |
|
| x1 |
y1 |
z1 |
r1 |
| xN |
yN |
zN |
rN |
The first line of a dataset contains a positive integer N
Each of the following N
N, u, v, w, xi, yi, zi
You can assume that the distance between the surfaces of any two spheres is no less than 0.1. You can also assume that the origin (0, 0, 0) is located outside of any sphere, and is at least 0.1 distant from the surface of any sphere.
The ray is known to be reflected by the sphere surfaces at least once, and at most five times. You can assume that the angle between the ray and the line connecting the sphere center and the reflection point, which is known as the angle of reflection (i.e.
The last dataset is followed by a line containing a single zero.
Output
For each dataset in the input, you should print the x -
Sample Input Download
Sample Output Download
Tags
Discuss
Description
On a small planet named Bandai, a landing party of the starship Tadamigawa discovered colorful cubes traveling on flat areas of the planet surface, which the landing party named beds. A cube appears at a certain position on a bed, travels on the bed for a while, and then disappears. After a longtime observation, a science officer Lt. Alyssa Ogawa of Tadamigawa found the rule how a cube travels on a bed.
A bed is a rectangular area tiled with squares of the same size.
- One of the squares is colored red,
- one colored green,
- one colored blue,
- one colored cyan,
- one colored magenta,
- one colored yellow,
- one or more colored white, and
- all others, if any, colored black.
Initially, a cube appears on one of the white squares. The cube's faces are colored as follows.
| top | red |
| bottom | cyan |
| north | green |
| south | magenta |
| east | blue |
| west | yellow |
The cube can roll around a side of the current square at a step and thus rolls on to an adjacent square. When the cube rolls on to a chromatically colored (red, green, blue, cyan, magenta or yellow) square, the top face of the cube after the roll should be colored the same. When the cube rolls on to a white square, there is no such restriction. The cube should never roll on to a black square.
Throughout the travel, the cube can visit each of the chromatically colored squares only once, and any of the white squares arbitrarily many times. As already mentioned, the cube can never visit any of the black squares. On visit to the final chromatically colored square, the cube disappears. Somehow the order of visits to the chromatically colored squares is known to us before the travel starts.
Your mission is to find the least number of steps for the cube to visit all the chromatically colored squares in the given order.
Input
The input is a sequence of datasets. A dataset is formatted as follows:
w d
c11 .. cw1
...
c1d ... cwd
v1v2v3v4v5v6
The first line is a pair of positive integers w
The integers w
Each character cij #, the corresponding square is colored white and is the initial position of the cube.
The string v1v2v3v4v5v6
Output
For each input dataset, output the least number of steps if there is a solution, or ``unreachable" if there is no solution. In either case, print it in one line for each input dataset.