Want to try solving this problem? You can submit your code online if you log in or register.
You have bought N identical flowers to arrange into three vases. As an expert in interior design, there are three important rules you must follow:
Your task is to determine a possible way to arrange the flowers. Note that there may be multiple possible solutions, or none at all.
The only line of input will contain a single integer: the number of flowers N.
Your program should output three space-separated integers, describing how many flowers to put into each vase. If there are multiple possible ways to arrange the flowers, any will do.
If it is impossible to place flowers according to the rules, print 0 0 0 instead.
15
4 5 6
105
100 2 3
4
0 0 0
In the first sample input, you have N = 15 flowers. One way you can arrange the flowers is to put 4 flowers in the first vase, 5 flowers in the second vase and 6 flowers in the third vase. There are other possible solutions.
In the second sample input, you have N = 105 flowers. One way you can arrange the flowers is to put 100 flowers in the first vase, 2 flowers in the second vase and 3 flowers in the third vase. There are other possible solutions.
In the third sample input, you have N = 4 flowers. It is impossible to arrange flowers in vases according to your interior design rules, so the only correct output is 0 0 0.
For all cases, 1 ≤ N ≤ 100,000.
For Subtask 1 (20 marks), N = 10.
Hint: There is only one test case in this subtask, so try working out the answer by hand.
For Subtask 2 (30 marks), N = 1000.
Hint: There is only one test case in this subtask, so try working out the answer by hand.
For Subtask 3 (35 marks), N ≥ 1000.
Hint: Can you modify your answer for N = 1000 to work for larger values of N?
For Subtask 4 (15 marks), no further constraints apply.
Hint: Think about when it is impossible to arrange the flowers.
Privacy
statement
© Australian Mathematics Trust 2001-2023
Page generated: 24 March 2023, 9:28pm AEDT