Divorce and child custody in an ideal society