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

相关推荐

10-03 17:08
已编辑
西安电子科技大学 Java
点赞 评论 收藏
分享
菠落蜜:这个是系统自动投的,不是hr主动打招呼。更抽象的还有ai回复
我的秋招日记
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务