H · The Two Note Rag
Since most computers are binary machines, both powers of two and problems that
involve only two
values are important to computer scientists. The fol lowing problem has to do
with powers of two and
the digits 1 and 2.
Some powers of two as decimal values , such as 29 = 512 and 289 =
618,970,019,642,690,137,449,562,112 end in a string of digits consisting only of
1's and 2's
(12 for 29 and 2112 for 289). In fact, it can be proved that:
For every integer R, there exists a power of 2 such that 2k uses
only the digits 1 and 2 in its last R digits.
This is shown a bit more clearly in the following table:
| R |
Smallest K |
2k |
 |
Your job is to write a program that will determine, for
given R, the smallest K such that 2k ends in a
string of R digits containing only 1's and 2's.
Input
The first line of the input contains a single decimal integer, N, 1 ≤ N ≤ 50,
the number of problem data
sets to follow. Each data set consists of a single integer R, 1 ≤
R ≤ 20, for
which we want a power of
2 ending in a string of R 1's and 2's.
Output
For each data set, you should generate one line of output with the following
values: The data set
number as a decimal integer (start counting at one), a space, the input value R,
another space, and
the smallest value K for which 2k ends in a string of R 1's and 2's.
| Sample Input |
Sample Output |
 |
I · Joe’s Triangular Gardens
Joe’s landscaping company specializes in gardens for computer geeks who have
just had their
company go public. One of his signature features is a round pool surrounded by a
tiled patio in the
form of an equilateral triangle where the edge of the pool is tangent to each
side of the triangle at its
midpoint.

Unfortunately, some of Joe’s customers are not satisfied
with an equilateral triangle, usually in the
center of the garden. Some want it in a corner or next to a slope or some other
layout. Joe would
like the option of offering arbitrary triangular patios with an elliptical pool
which is tangent to each side
at the center of the side. For example:

Joe knows how to draw an ellipse by putting two stakes in
the ground (at the foci of the ellipse), tying
a rope between them and dragging a marker stick inside the rope. What Joe would
like is for the
customer to de termine where the corners of the triangle will be and then measure
the location of the
triangle vertices and compute where to put the stakes and how long to make the
rope.
Write a program, which takes as input the three vertices
and
of a triangle
and computes an ellipse inscribed in the triangle, which is tangent to each side
of the triangle at its
midpoint. The output is the coordinates of the two foci of
the ellipse and the length of the rope (which
is the sum of the distances from the foci to any point on the ellipse.
Input
The first line of input contains a single integer N, (1 ≤ N ≤ 1000) which is the
number of data sets that
follow. Each data set consists of a single line of input containing 6 space
separated floating point
numbers
giving the coordinates of the vertices of a triangle.
Output
For each data set, you should generate one line of output with the following
values: The data set
number as a decimal integer (start counting at one), a space and five floating
point values accurate
to two decimal places each separated by a single space. The values are
where
is one focus of the ellipse,
is the other focus of the
ellipse and
is the sum of the
distances from the foci to any point on the ellipse (e.g. the length of the
rope). The foci should be
listed in increasing lexicographical order (i.e.
and if
). Note that in the
case the ellipse is a circle , the two foci are the same (e.g. the center of the
circle).
| Sample Input |
Sample Output |
 |