package yukicoder210; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); double[] p=new double[n+1]; double[] q=new double[n+1]; for(int i=0;i queue = new PriorityQueue(n, new Comparator(){ public int compare(double[] x, double[] y) { return -Double.compare(x[0], y[0]); } }); for(int i=1;i<=n;i++){ queue.add(new double[]{p[i]*q[i],(double)i});//部屋を探して見つかる確率 } double E=0; for(int i=1;i<900000;i++){ double[] a=queue.poll(); E+=a[0]*i; a[0]=a[0]*(1-q[(int)a[1]]); queue.add(a); } System.out.println(E); } }