Hello friends, if someone wants to help me with one task.

(I want example)

The task is:

One calculator can make two operations (multiply and subtract).

Return the minimum number of operations needed to get to target (or -1).

Example:

Your multiply number is 5

Your subtract number is 7

Your target number is 20

Starting with 1, we have:

1*5*5=25

25-7-7-7=4

4*5=20

Since we used 3 multiplications and 3 subtractions, the total amount is 6

Method

int getCount(int M, int S, int T)

Input parameters:

M - integer, the number used to multiply

S - integer, the number used to subtract

T - integer, the target number

Return value:

int, minimum number of operations needed to get to target (or -1)

I can't solve this problem because I have problem with the dynamic programming, so if anyone wants to help me (give example, or code with example...) I would be very grateful.

Thanks.