Question: I need some help on this because I can't figure it out.

Given only +, -, /, \* (arithmetic operations) and the value x where x > 0, Is there a way to write 787 with at most 28 arithmetic operations?

Best I could come up with is 29 operations with a dynamic programming code (i can post it here upon request). I know that it can be <= 28 because it comes from a programming competition problem. So, my assumption is that I'm lacking something with the code.

Answers for first few values for better understanding:

```
0: xx-     ops = 1
1: xx/     ops = 1
2: xx+x/   ops = 2
3: xxx++x/ ops = 3

```

The above table is in postfix, but can easily be infix. Fixation doesn't matter. The number before the colon is the goal value, the expression evaluates to that goal value and the `ops` value is the number of operations in the expression.

Answer: 
A similar sequence is <https://oeis.org/A005245>, where they use $1$s and just addition and multiplication. They count the number of $1$s, which I think should be no less than yours because they don't need to divide by $x$ at the end. 

In that sequence, they seem to be working with 
$$787=2\cdot 3(2\cdot 5 \cdot (4 \cdot 3 +1)+1)+1$$
which needs $22\ 1$s. As that has $22$ operands and $5$ multiplies it should take $28$ operators.
With Ross Millikan's answer, I replaced the constants with (x+x+..)/x then distruted the common divisions between addends to reduce the operations. I got this:
`((x+x)/x*(x+x+x)*(((x+x)/x*(x+x+x+x+x)*(((x+x+x+x)/x*(x+x+x)+x)/x)+x)/x)+x)/x` which has 27 operations.

So I guess, what's missing in my DP is the ability to cancel out common division.

For future reference, I wrote code to generate the minimum expression needed to build Y. Here: <https://github.com/mightymercado/icpc-solutions/blob/master/2016-regionals-manila/E.cpp>