In a software company, Mrs. Ellie has to schedule tasks
on her ten machines.
As she is a great fan of mathematics, she starts looking
for a method to assign tasks and working days for each machine.
First, she tries to find out a relation between the number
of tasks she has to schedule on a specific day and the corresponding day.
This is what she notices:
(Mrs. Ellie hates leap years and she never works that year, so assume 365 days)
Day Day Number Number of Tasks
1 January 1 1
3 January 3 1
4 January 4 2
5 January 5 3
6 January 6 3
. . .
. . .
27 January 27 29
. . .
. . .
24 March 83 125
. . .
. . .
1 August 213 406
. . .
. . .
3 November 307 632
. . .
. . .
31 December 365 779
Mrs. Ellie is clever enough to notice that the number of tasks for a specific day number n is SIMPLY the number of digits of n! So this is what she decides:
She enumerates her machines from 0 to 9, then each day, she computes the factorial of n (the day number of that day). Since the number of digits of n! corresponds exactly to the number of tasks for that day, she has just to assign to a machine i, Ti tasks where Ti is the frequency of the digit i in the number n!.
Example:
Day Number 32(1st of February):
32!=263130836933693530167218012160000000 (36 digits)
So, on the 1st of February, there will be 36 tasks and
the machines-tasks schedule will be:
Machine 0 has 10 tasks
Machine 1 has 5 tasks
Machine 2 has 3 tasks
Machine 3 has 7 tasks
Machine 4 has no task
Machine 5 has 1 task
Machine 6 has 5 tasks
Machine 7 has 1 task
Machine 8 has 2 tasks
Machine 9 has 2 tasks
Program:
Your program should read the day number from the input
file, convert it to the corresponding day, then compute the machines-tasks
schedule for that day as described in the sample output.
The input file is a set of day numbers(1-365) each on
a different line and the end of file is a line containing the null number
0.
The output file should be a set of machines-tasks schedule
for each day number n.
Each set is composed of a first line consisting of the
day and the month corresponding to n, then 10 lines with the form of :
Machine i : Ti (one space between Machine
and i, i and :, : and Ti)
Where i goes from 0 to 9 and Ti is the
frequency of the digit i in the number n!
Each line should end with the character ‘\n’.
Sample Input File:
8
32
364
0
Sample Output File:
8 January
Machine 0 : 2
Machine 1 : 0
Machine 2 : 1
Machine 3 : 1
Machine 4 : 1
Machine 5 : 0
Machine 6 : 0
Machine 7 : 0
Machine 8 : 0
Machine 9 : 0
1 February
Machine 0 : 10
Machine 1 : 5
Machine 2 : 3
Machine 3 : 7
Machine 4 : 0
Machine 5 : 1
Machine 6 : 5
Machine 7 : 1
Machine 8 : 2
Machine 9 : 2
30 December
Machine 0 : 158
Machine 1 : 69
Machine 2 : 61
Machine 3 : 74
Machine 4 : 74
Machine 5 : 74
Machine 6 : 59
Machine 7 : 70
Machine 8 : 69
Machine 9 : 68