Problem F
Coprimes
Input: Standard Input
Output: Standard Output
Time Limit: 2 Seconds
How many times must a man look up
Before he can see the sky?
Yes, 'n' how many ears must one man have
Before he can hear people cry?
Yes, 'n' how many deaths will it take till he knows
That too many people have died?
The answer, my friend, is blowin' in the wind,
The answer is blowin' in the wind.
Shahriar has decided to give a party to
all those who will solve this problem so he definitely wants an efficient and
intelligent solution so that number of people in the party is small and of
course his budget is limited :).
Input
Output
For each line of
input you should give several lines of outputs. The description of output for
each line of input is given in the paragraph below:
First line should
be the serial of the output. Next lines should contain all possible partitions
of S into t co-prime numbers. Each line should contain
one possible partition. In a partition the printed numbers should be ordered in
non-decreasing order and two consecutive numbers should be separated by a
single space. The partitions should be printed in ascending order. Let say one
partition is P1=a1, a2 …,
an and another partition is P2=b1, b2,
…, bn. ak and bk are not equal and
for all value of i(0<i<k) ai=bi. Then partition P1>P2 iff ak>bk and P1<P2 iff ak<bk. There can be around
15000 lines in the output file in total.
2 40 6 8 3 |
Case
1: 1
1 1 1 1 35 1
1 1 1 5 31 1
1 1 1 7 29 1
1 1 1 11 25 1
1 1 1 13 23 1
1 1 1 17 19 1
1 1 3 5 29 1
1 1 3 11 23 1
1 1 5 9 23 1
1 1 5 11 21 1
1 1 5 13 19 1
1 1 7 11 19 1
1 1 7 13 17 1
1 1 9 11 17 1
1 3 5 7 23 1
1 3 5 11 19 1
1 3 5 13 17 1
1 3 7 11 17 1
1 5 7 9 17 1
1 5 9 11 13 1
3 5 7 11 13 Case
2: 1
1 6 1
2 5 1
3 4 |
Problemsetter: Shahriar Manzoor, Member of Elite Problemsetters' Panel
Special Thanks: Jimmy Mårdell, Member of Elite Problemsetters' Panel (Alternate Soln)
“I like to mess with things. I used to garden, but my traveling resulted in the demise of all but my peach trees. I can fix a car, but I won't fix yours. I like to write software, but I don't like to read yours. I can say "Please put down your pencils!" in several languages. After thirty years, I can still play a trumpet well enough to know that some practice would do wonders. I have no idiosyncrasies.”
- Bill Poucher