National Olympiad in Informatics, China, 2002
It is the year 3030, and Macsy is currently producing a batch of robots on Mars.
During the 1st second, he transfers robot no. 1 onto Mars. Robot no. 1 is used to produce more robots.
During the 2nd second, robot no. 1 produces its first robot — robot no. 2.
During the 3rd second, robot no. 1 produces another robot — robot no. 3.
Each second hereafter, robot no. 1 produces a new robot. The robot produced during the
After a robot is produced, it immediately begins work. Robot no.
When a robot is at rest, its memory will be ported to the robot born at that second. For example, when robot no. 6 is born, robots no. 2 and 3 are resting. Thus, robot no. 6 will receive a copy of the memories of robots no. 2 and 3. We shall call robots no. 2 and 3 the teachers of robot no. 6.
If two robots are not teacher and student, and also do not share the same teacher, then the knowledge of these two robots are considered mutually independent. Note: Robot no. 1's knowledge is independent with respect to all other robots (since only robot no. 1 can produce other robots), it is also not any other robot's teacher.
A robot's independency number refers to the number of robots numbered small than it, while also being independent to it. For example, robot no. 1 has an independency number of 0, robot no. 2 has an independency number of 1 (robot no. 1 is independent to it), and robot no. 6 has an independency number of 2 (robots no. 1 and 5 are independent to it, robots no. 2 and 3 are both its teachers, and robot no. 4 share the same teacher with it — robot no. 2).
The newly produced robots have 3 different types of jobs. For a given robot no.
Robot no.
To simplify your calculations, Macsy has already performed a factorization of
Input Specification
The first line of input contains the positive integer
The next
Output Specification
The output should contain three lines.
Line 1 should contain the sum of the independency scores of all the politicians amongst robot no.
Line 2 should contain the sum of the independency scores of all the soldiers amongst robot no.
Line 3 should contain the sum of the independency scores of all the scholars amongst robot no.
Sample Input
3
2 1
3 2
5 1
Sample Output
8
6
75
Explanation
Scoring
The output contains 3 numbers. For each test case, your score out of 10 will be:
- 10 if your program calculates all 3 numbers correctly;
- 7 if your program only calculates 2 numbers correctly;
- 4 if your program only calculates 1 number correctly; and
- 0 if your program does not calculate any number correctly.
Problem translated to English by .
Comments