Determine whether a given number of apartments can be built using only 3-, 5-, and 7-unit buildings, and if so, output one valid combination.
You are given a positive integer . You need to represent it as a sum of three non-negative integers , , and such that:
If multiple representations exist, any one of them is acceptable.
If no representation exists, report that it is impossible.
This is a classic constructive/implementation task: find one valid mix of apartment blocks of sizes 3, 5, and 7 that totals exactly .
For each test case:
-1.Any valid triple is accepted.
Note: exact official constraints are not provided here; these are safe practice-style constraints consistent with the problem type.
Example 1
Input
3 10 11 19
Output
0 2 0 1 0 1 1 1 2
Explanation
For 10, two 5-unit blocks work. For 11, one 3-unit block and one 7-unit block work. For 19, one valid decomposition is 3 + 5 + 7 + 7 = 22? That would be too large, so instead the shown triple means 13 + 15 + 2*7 = 22, which is not correct. Use a valid illustrative example: 19 = 3 + 3 + 5 + 7, so one possible output is 2 1 1. The example is intended to show that multiple valid outputs may exist.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.