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-09 16:39
已编辑
英俊的靓仔offer...:我感觉吧第二个寻迹小车的项目有点配不上你的学历了,写上去扣分了都可能对你来说,好歹是211硕士嘛,写在我这种二本混子的简历上还说得过去,个人观点哦,能再有个好点的项目应该会好很多,或者干脆不写第二个换个啥实习经历?
点赞 评论 收藏
分享
牛客70961307...:你这项目认真的吗?
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务