hdoj4405-Aeroplane chess
来源:互联网 发布:plc编程100例梯形图 编辑:程序博客网 时间:2024/06/08 07:08
求期望值,体重说明,如果可以flight的话就直接到达规定那个点,用f数组将两个点连在一起就可以,反之,就要求打骰子后的期望啦,e[i] =∑(e[i + k] * 1 / 6) + 1(k为点数1~6,1/6为致筛子的概率,因为不可以flight就要置一次筛子,所以+1)。
/************************************************************************* > File Name: hdoj4405.cpp > Author: AcToy > Mail: ycsgldy@163.com > Created Time: 2013年07月17日 星期三 09时19分05秒 ************************************************************************/#include <algorithm>#include <iostream>#include <cstring>#include <cstdlib>#include <climits>#include <cstdio>#include <string>#include <vector>#include <queue>#include <cmath>#include <stack>#include <map>#include <set>using namespace std;typedef unsigned int u32;typedef long long i64;typedef unsigned long long u64;typedef vector<int> IV;typedef vector<bool> BV;typedef pair<int,int> II;typedef vector<II> IIV;#define For(t,v,c) for(t::const_iterator v=c.begin(); v!=c.end(); ++v)const int INF = 0x7FFFFFFF;const double eps = 1E-10;const double PI = acos(-1);const int maxn = 100000;double e[maxn];int f[maxn], n, m;int main () { while(scanf("%d%d", &n, &m) == 2 && n) { memset(f, 0, sizeof(f)); for(int i = 0; i <= n; e[i] = 0, ++i) ; for(int i = 1; i <= m; ++i) { int x, y; scanf("%d%d", &x, &y); f[x] = y; } for(int i = n - 1; i >= 0; --i) { if(f[i]) e[i] = e[f[i]]; else { for(int j = 1; j <= 6; ++j) { if(i + j <= n) e[i] += e[i + j] * 1.0 / 6; else break; } e[i] += 1.0; } } printf("%.4lf\n", e[0]); } return 0;}
- hdoj4405-Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- HDU4405 Aeroplane chess
- hdu4405 Aeroplane chess 期望
- HDU 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU 4405Aeroplane chess
- HDU4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- HDU4405-Aeroplane chess
- Delphi7语言基础20130717-1
- MS-SQL生成表里数据的insert插入语句
- Ubuntu上的android sdk: ./emulator: No such file or directory
- C++ 模拟C#的静态函数
- 一个好的C程序员应该做到
- hdoj4405-Aeroplane chess
- 一位软件工程师的6年总结
- HTML5 Canvas自定义圆角矩形与虚线(Rounded Rectangle and Dash Line)
- par中的mex参数
- Csharp: Detect Mobile Browsers
- 网页返回顶部
- tcpdump抓包分析详解
- PHP伪静态
- sql server一般性问题