import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m="";
while((m=br.readLine())!=null){
StringTokenizer st=new StringTokenizer(m);
int p=Integer.parseInt(st.nextToken());
int q=Integer.parseInt(st.nextToken());
int r=Integer.parseInt(st.nextToken());
int s=Integer.parseInt(st.nextToken());
BigInteger bg=c(p,q).multiply(BigInteger.valueOf(1000*1000));
BigInteger bg2=c(r,s);
bg=bg.divide(bg2);
double ans=bg.doubleValue();
ans/=1000000;
String formattedString = String.format("%.5f\n", ans);
sb.append(formattedString);
}
System.out.print(sb);
}
static BigInteger c(long n, long r) {
BigInteger ans = BigInteger.ONE;
r = Math.min(r, n - r);
long i;
for (i = 1; i < r+1; i++) {
ans=ans.multiply(BigInteger.valueOf(n - r + i));
ans=ans.divide(BigInteger.valueOf(i));
}
return ans;
}
}
No comments:
Post a Comment