Let middle piece's length be M
Then longest's and shortest's lengths are: 3M and 3M - 23, respectively
We then get: M + 3M + 3M - 23 = 40
7M = 63
Middle piece's length, or
You should now be able to find the length of the other 2 pieces.
NUMBER LONG x+23 MIDDLE (1/3)(x+23) SHORT x Sum 40