It's pretty easy to see what arithmetic we have to do isn't it? We start with $1000 and divide it, evenly, between two groups so each group gets $1000/2= $500. The first group divides its $500 among 5 children. It doesn't say "equally" now but assuming that, each child would get $500/5= $100. The second group divides its $500 between two brothers so each brother gets $500/2= $250.
For a "formula", take the initial amount to be "A" rather than the specific amount. Then the first group gets A/2 dollars and divides it among 5 children so each child gets (A/2)/5= A/10 dollars. The second group gets A/2 dollars also and divides it between two brothers so each brother gets (A/2)/2=A/4 dollars.
If you want to be really fancy you could say that person "p" gets (A/10)q(p)+ (A/4)(1- q(p)) where q(p)= 1 if "p" is one of the five children and q(p)= 0 if "p" is one of the two brothers.