function [result]=PV_HW4(x1,x2,x3)
n=x1+x2+x3;
if n<10
   result=pv_hw(x1,x2,n);
   
else   
   
if or(and(x1<x3,x2>=n/2),and(x1>x3,x2<n/2))
   x1=n-x1-x2;
   x3=n-x3-x2;
end   

sln(1)=0;
for s=1:2*n+1
   sln(s+1)=sln(s)+log(s);
end   


lnrvobs=sln(n+2+1)+sln(2*x1+x2+1)+sln(2*x3+x2+1)+(x2-1)*log(2)-sln(x1+1)-sln(x2+1)-sln(x3+1)-sln(2*n+1+1)-log(3)+log(5-12*(2*x1+x2+1)*(2*x3+x2+1)/((2*n+2)*(2*n+3)));

soma=0;
for j=0:n
   for i=0:floor((n-j)/2)
      lnrv=sln(n+2+1)+sln(2*i+j+1)+sln(2*(n-i-j)+j+1)+(j-1)*log(2)-sln(i+1)-sln(j+1)-sln(n-i-j+1)-sln(2*n+1+1)-log(3)+log(5-12*(2*i+j+1)*(2*(n-i-j)+j+1)/((2*n+2)*(2*n+3)));
      if lnrv<=lnrvobs
         f0=exp(lnrv)*2/(n+1)/(n+2);
         if i==(n-j)/2
            soma=soma+f0;
         else soma=soma+2*f0  ;
         end   
      end
   end
end
result=soma;

end