The Antikythera Mechanism
The Antikythera Mechanism, also known as the Antikythera computer, or Antikythera astrolabe, is an ancient artifact that functioned as an analog mechanical computer and an instrument for astronomical observations, displaying similarities to a complex clockwork mechanism. Its study continues by experts from Greek and foreign universities. The research results confirmed that the mechanism contains toothed wheels rotating around axes. The operation of the mechanism led to at least dials, each with one or more pointers.
By appropriately rotating some of the wheels, the others are forced to rotate (in at least one case, in a differential rotation). For example, if the first wheel had teeth and the second had , with three rotations of the first, the second would be forced into two rotations. With a highly simplified approach, we can assume that the first wheel forced the rotation of the second, the second forced the third, and so on (see diagram). The rotations of the wheels other than the first were not always whole numbers but also included a decimal part of three digits. In this way, and in relation to the rotations of the first wheel, astronomical predictions of the positions of the Sun, Moon, and possibly the five known planets or the timing of astronomical phenomena (e.g., eclipses) could be made during its era.
Problem
Develop a program in one of the IOI languages (PASCAL, C, C++, Java) that, after reading the number of toothed wheels, the number of teeth of each wheel, and the number of rotations completed by the first wheel, returns the number of rotations completed by five wheels selected from the input file.
Input Files:
The input files with the name astrolavos.in are text files with the following structure: On the first line, there is an integer Λ (6 Λ 1000), the number of wheels in the mechanism. On the second line, there are Λ integers , separated in two by a space. Each number Μ (5 Μ 10.000) corresponds to the number of teeth on each toothed wheel. On the third line, there are six integers , separated by spaces. The first number corresponds to the number N of rotations forced by the first wheel (1 N 3.660.000), and the next five are in increasing order representing the wheels for which the number of rotations is requested .
Output Files:
The output files with the name astrolavos.out are text files with the following structure. They have exactly one line with five numbers. Each number in the format .ddd has at least four digits, of which exactly three are decimal, and corresponds to the number of rotations performed by the requested wheel, in order.
Examples of Input - Output Files:
1o
STDIN (astrolavos.in)
6
10 15 30 20 30 60
30 2 3 4 5 6
STDOUT (astrolavos.out)
20.000 10.000 15.000 10.000 5.000
The first example corresponds to the diagram located above.
2o
STDIN (astrolavos.in)
30
100 95 95 90 90 85 85 80 80 75 75 70 70 65 65 60 60 55 55 50
50 45 45 40 40 35 35 30 30 60
366 3 13 24 25 30
STDOUT (astrolavos.out)
385.263 522.857 915.000 915.000 610.000
Notes:
Formatting: In both the input and the output, each line terminates with a newline
character.
Maximum execution time: 1sec.
Maximum available memory: 64MB.
Headers in the source code: At the beginning of your source code, you should use the following headers.
(* USER: username
LANG: PASCAL
TASK: astrolavos *)
for PASCAL coders
/* USER: username
LANG: C
TASK: astrolavos */
for C coders
/* USER: username
LANG: C++
TASK: astrolavos */
for C++ coders
/* USER: username
LANG: Java
TASK: astrolavos */
for Java coders
# USER: username
# LANG: Python
# TASK: astrolavos
for Python coders
Based on the form of the Greek inscriptions it bears, it is dated between 150 B.C. and 100 B.C., and was discovered in a shipwreck off Antikythera. The shipwreck was discovered in 1901 at a depth of approximately 40 to 64 meters, and many treasures, statues, and other objects were recovered by sponge divers from Symi and are now in the National Archaeological Museum in Athens. On May 17, 1902, Valerios Stais, an archaeologist and director of the Archaeological Museum, noticed that one of the findings had a toothed wheel embedded and visible inscriptions with astronomical terms. Since then, scientific research on this mechanism has been continuous. The ancient Greeks called it a pinakidio, let's translate it as a tablet!
Comments