ACdream原创群赛(13)のwuyiqi退役专场 F The Arrow

F

首先是要理解概率求期望这种题目是用递归来解的!

大概规律就是:

完成事件A的期望是Ea,一次完成的概率是pa,那么

Ea = pa * Ea + (1 + Ea) * (1 - pa)

如果有好多种可能,比方说完成一个事件A的同时,也有诸如事件B的概率期望pb,Eb,事件C的概率期望pc,Ec等等等等,那么就分别写出来:

Ea = pa * Ea + (1 + Ea) * (~pa) + pb * (1 + Eb) + pc * (1 + Ec) + ...

其中~pa是除了这些已知的事件发生概率以外,的概率,也就是~pa = 1 - pa - pb - pc - ...

所以这个题的期望递推公式就是

E1 = 1/6 * E1 + 5/6 * (1 + E1)

E2 = 1/6 * E2 + 1/6 * (1 + E1) + 4/6 * (1 + E2)

E3 = 1/6 * E3 + 1/6 * (1 + E1) + 1/6 * (1 + E2) + 3/6 * (1 + E3)

E4 = 1/6 * E4 + 1/6 * (1 + E1) + 1/6 * (1 + E2) + 1/6 * (1 + E3) + 2/6 * (1 + E4)

E5 = 1/6 * E5 + 1/6 * (1 + E1) + 1/6 * (1 + E2) + 1/6 * (1 + E3) + 1/6 * (1 + E4) + 1/6 * (1 + E5)

E6 = 1/6 * E6 + 1/6 * (1 + E1) + 1/6 * (1 + E2) + 1/6 * (1 + E3) + 1/6 * (1 + E4) + 1/6 * (1 + E5)

E7 = 1/6 * (1 + E1) + 1/6 * (1 + E2) + 1/6 * (1 + E3) + 1/6 * (1 + E4) + 1/6 * (1 + E5) + 1/6 * (1 + E6)

E8 = 1/6 * (1 + E2) + 1/6 * (1 + E3) + 1/6 * (1 + E4) + 1/6 * (1 + E5) + 1/6 * (1 + E6) + 1/6 * (1 + E7)

规律很明显。。。

/****
	*COPYRIGHT NOTICE
    *Copyright (c) 2014
    *All rights reserved

	*@author    Shen
	*@name		F
	*@file		G:\My Source Code\比赛与日常练习\0608 - wuyiqi退役赛\F\F.cpp
	*@date		2014/6/8 20:21
	*/

//#pragma GCC optimize ("O2")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define _CRT_SECURE_NO_WARNINGS
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

/*//STL
#include <map>
#include <vector>
#include <list>
#include <stack>
#include <deque>
#include <queue>
*/

/*//Computational Geometry
#include <complex>
#define x real()
#define y imag()
typedef complex<double> point;
*/

typedef long long int64;

const double p6 = 1.0 / 6.0;
double res[100005];

int t, q;

void init()
{
	int i = 1, j = 7;
	double tmp = 36.0;
	for (; j < 100005; i++, j++)
	{
		res[j] = p6 * (6.0 + tmp);
		tmp = tmp + res[j] - res[i];
	}
}
void solve()
{
	scanf("%d", &q);
	printf("%.2lf\n", res[q]);
}

int main()
{
	res[1] = res[2] = res[3] = res[4] = res[5] = res[6] = 6;
	init();
	scanf("%d", &t);
	while (t--) solve();
	return 0;
}

ACdream原创群赛(13)のwuyiqi退役专场 F The Arrow,布布扣,bubuko.com

时间: 2024-08-09 15:58:46

ACdream原创群赛(13)のwuyiqi退役专场 F The Arrow的相关文章

ACdream原创群赛(13)のwuyiqi退役专场 H Salmon And Cat

H 首先是要姿势正确! 注意完美数的生成机: 2+2a+2b+ab ab都是完美数 假设生成完美数c c = 2 + 2a + 2b + ab c + 2 = ab+2a+2b+4 c + 2 = (a + 2)(b + 2) 然后一开始只有两个完美数1和3. 所以所有的完美数只有质因数分解之后都是类似于 N = (3 ^ x) * (5 ^ y) 但是5不是完美数. 然后就没事了... /**** *COPYRIGHT NOTICE *Copyright (c) 2014 *All right

ACdream原创群赛(13)のwuyiqi退役专场 C True love

True love Time Limit: 4000/2000 MS (Java/Others)     Memory Limit:128000/64000 KB (Java/Others) Problem Description Is there true love in the world?maybe or not, god knows! We know there are some complex relationships between ds and cxlove, they fell

ACdream原创群赛(18)のAK&#39;s dream题解

只做了4题水题ADGI A题需要注意的就是“[...]”的输出了,何时输出,何时不输出. 1 #include <stdio.h> 2 int main() 3 { 4 int n, cur, d; 5 int cnt = 1; 6 while(scanf("%d%d%d",&n,&cur,&d)!=EOF) 7 { 8 printf("Case #%d: ",cnt++); 9 if(cur==1) 10 printf(&quo

ACdream原创群赛__15

这场感觉题目确实还算可以,不过,说好的每题10s效果上却不理想.这个时限还算比较紧.因为时间不是按绝对的多出几秒来计算,而是几倍来计算的. 比赛做的不好,后面又去做了一下. A:典型的数位DP,一直坑在这里. E:求f(f(f(n)))%p.f()表示斐波那契数.关于求斐波那契数模的循环节是有特定的数学定理和方法的.我也不知道,但是看了结论之后自己会实现了.首先,把p因数分解,ai^pi,显然最终的循环节就等于这些单独因子计算循环节的lcm.同时ai^pi的循环节又是G(ai)*ai^(pi-1

ACdream原创群赛(18)のAK&#39;s dream

ACdream原创群赛(18)のAK's dream 题目链接 A:水题,直接模拟题意去搞即可 D:贪心+组合数学,把剑和英雄都从小到大排序,每次计算该英雄能用前几把剑cnt,cnt减去之前有多少人就是该英雄能选的,种数乘上cnt - 之前有多少人 F:DP,dp[i][j][2]表示第i天,用了j次修改,当前状态是A还是B,然后去转移即可 G:水题,直接用字符串处理即可,把数字都加上前导零方便判断 H:几何,利用正弦定理,余弦定理乱搞就可以了 I:水题,直接每个位置推出来输出,化简利用gcd即

acdream原创群赛(16) --- B - Apple

<传送门> B - Apple Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitStatus Problem Description Alice and Bob are coming.This time, they are playing with apples. Initially, there are N baskets and M apples. Both bas

ACdream原创群赛(16) F

MST Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitStatus Problem Description Given a connected, undirected graph, a spanning tree of that graph is a subgraph that is a tree and connects all the vertices togeth

ACdream原创群赛(16) J

Sum Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) SubmitStatus Problem Description You are given an N*N digit matrix and you can get several horizontal or vertical digit strings from any position. For example: 123 4

ACdream原创群赛(11)の风神日华神专场 C.神奇的%系列一

3.算法综合实践——搜索引擎 上网搜索有关“搜索引擎”的相关资料,包括但不限于以下方面(至少要有2个方面):搜索引擎岗位要求.搜索引擎工作原理.搜索引 擎涉及到教材中哪些算法.搜索引擎的盈利模式.搜索引擎源码链接.国内外搜索引擎公司现状等. <1>搜索引擎指自动从因特网搜集信息,经过一定整理以后,提供给用户进行查询的系统.因特网上的信息浩瀚万千,而且毫无秩序,所有的信息像汪洋上的一个个小岛,网页链接是这些小岛之间纵横交错的桥梁,而搜索引擎,则为用户绘制一幅一目了然的信息地图,供用户随时查阅.