import java.util.Arrays; import java.util.Scanner; public class Main_2 {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         int n = scanner.nextInt();         int[] x = new int[51];         for (int i = 0; i < n; i++) {             int M = scanner.nextInt();             x[M]++;         }         double expection = 0;         double temp2 = 1;         double temp1 = 1;         for (int i = 50; i > 0; i--) {             if (x[i] > 0) {                 temp1 *= Math.pow(i - 1, x[i]) / Math.pow(i, x[i]);                 double pro = temp2 - temp1;                 temp2 = temp1;                 expection += i * pro;                 x[i - 1] += x[i];             }         }         System.out.printf("%.2f", expection);     } }
点赞 1

相关推荐

02-01 19:48
门头沟学院 Java
神哥了不得:(非引流)直接暑期吧,没时间日常了,老鱼简历把水印去了,或者换个模板,简历字体大小都不太行,建议换2个高质量的项目,面试应该还会再多一些
点赞 评论 收藏
分享
牛客网
牛客企业服务