How many of each pill to take to achieve the total daily dose A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg):
1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50
In words: any whole number less or equal to 20, then at 2.5mg increments up to 50.
Your task is to determine how many pills of each size the patient should take to get to their total dose, minimizing the total number of pills they have to take.
Input: the total daily dose
Output: the respective number of 5mg, 2.5mg, and 1mg the patient needs to take, in any consistent format.
This is code golf. Fewest number of bytes wins.
Examples: (output is number of 1, 2.5, and 5 mg pills)
1 =&gt; [1, 0, 0]
4 =&gt; [4, 0, 0]
7 =&gt; [2, 0, 1]
19 =&gt; [4, 0, 3]
22.5 =&gt; [0, 1, 4]
40 =&gt; [0, 0, 8]

Irrelevant: this is based on a true story. The drug is prednisone and I wrote a program to automate the production of a calendar for patients to use to titrate their doses, which is a challenging task for many elderly patients to do safely even if you give them written instructions. This challenge was part of the programming task.
R, 53 38 bytes

function(x)c(x%/%5,2*x%%1,(x&lt;20)*x%%5)

Try it online!
Output is in the order (5mg, 2.5mg, 1mg).
For the 2.5mg pills:

if the dose is an integer, we need 0 such pills. Indeed, 1 pill of 2.5 mg would not give an integer, and 2 pills of 2.5 mg can be replaced by a single 5mg pill
if the dose x is not an integer, we need exactly 1 such pill (similar argument), and then we call the function with the integer x-2.5.

The number of 5 mg pills is the integer division of the input by 5.
Note that because the input is restricted, the 1 mg pills are never needed when the input is ≥20. If the input is &lt;20, the number of 1mg pills is given by taking the input modulo 5.