Given two positive reals \$a\$ and \$b\$, output some positive reals \$r_i\$, such that \$\sum r_i=a\$ and \$\prod\left(r_i+1\right)=b\$. You can assume that it's possible. You can also assume that your float type have infinite precision.
2,3 => 2 2,4 => 1,1 or 1/2,(sqrt(57)+9)/12,(9-sqrt(57))/12 or etc. 2,5 => 1/3,1/2,2/3,1/2 or etc. 2,8 => (undefined behavior) 2,2 => (undefined behavior) e,2e => 1,e-1 or etc. (e is natural base, though any number>1 work) 3,e^3 => (undefined behavior) (It's possible to get as close as you want to e^3, but not reaching)
Shortest code wins.
- Given the assumption with infinite precision, you can't solve arbitrary equation if your language doesn't have such functions(you can still use functions like
Solvein Mathematica to solve such). In this case, some forms may have solution mathematically but you can't work it out, e.g. \$p,p,p,...,p,q\$ where \$p\$ and \$q\$ are reals. (At least software don't provide exact solution for