HDU 4586 Play the Dice(规律+推导)
来源:互联网 发布:js将list转换为数组 编辑:程序博客网 时间:2024/06/09 14:33
题目连接:HDU 4586 Play the Dice
题意:有一个n面的骰子,掷到i面的获得一个价值ai,还有m个特殊的面掷到这些面可以获得价值并且还可以获得再掷一次的机会,问游戏结束获得价值的期望。
思路:下面是3个面有2个特殊面(红色),掷三次的情况。
以下是推导:
注意:sum==0答案是0,n==m是inf
#include <stdio.h>int a[210];int b[210];int main(){int n;int i,m;while(scanf("%d",&n)!=EOF) {int sum=0;for(i=0;i<n;i++){scanf("%d",&a[i]);sum+=a[i];}scanf("%d",&m);for(i=0;i<m;i++) scanf("%d",&b[i]);if(sum==0) {printf("0.00\n");continue;}if(m==n) printf("inf\n");else printf("%.2lf\n",sum*1.0/(n-m));}return 0;}
2 0
- HDU 4586 Play the Dice(规律+推导)
- (hdu 4586) Play the Dice
- hdu 4586 Play the Dice(数论)
- Play the Dice(HDU OJ 4586)
- HDU-4586 Play the Dice (数学)
- HDU 4586 Play the Dice
- HDU 4586 Play the Dice
- hdu-Play the Dice
- hdu 4586 Play the Dice (概率+等比数列)
- HDU 4586 Play the Dice(概率+期望)
- HDU 4586 Play the Dice(概率入门)
- HDU 4586 Play the Dice 概率期望
- Play the Dice - HDU 4586 dp
- hdu 4586——Play the Dice
- HDU 4586 Play the Dice 数学期望
- Play the Dice - HDU 4586 期望dp
- HDU 4586 Play the dice (数学期望)
- HDU 4586 Play the Dice 简单思考
- hud1326 排序水题
- php中empty()和isset()函数的区别
- day12/WaitNotifyThread.java
- 数据结构:二叉搜索树
- 链表 Remove Duplicates from Sorted List II
- HDU 4586 Play the Dice(规律+推导)
- day13/Jibenshujuleixing.java
- 双向循环链表 函数的实现
- JavaScript扩展String的方法
- zoj-2563(1×3铺地砖)
- day13/MyIndexOfString.java
- LintCode 两个字符串是变位词
- 【cocos2dx】添加简单的按钮 MenuItemImage
- day13/MyReverseString.java