hdu3722Card Game 概率dp水题

//3中天气前一天天气为i转为第二天天气为j的概率为p[i][j]

//问第一天天气为i,n天后天气为j的概率

//dp[i][j][k]在第一天天气为j的情况下第n天的天气为j的概率

//dp[i][j][k] += dp[i-1][j][s]*dp[1][s][k] ;

#include<cstdio>

#include<cstring>

#include<iostream>

using namespace std ;

const int maxn = 1010 ;

double dp[maxn][3][3] ;

int main()

{

//freopen("in.txt","r" , stdin) ;

int T ;

scanf("%d" , &T) ;

while(T--)

{

memset(dp , 0 ,sizeof(dp)) ;

for(int i = 0; i < 3 ;i++)

for(int j = 0 ;j < 3 ; j++)

scanf("%lf" , &dp[1][i][j]) ;

for(int j = 0;j < 3;j++)

for(int i = 2;i < maxn ;i++)

for(int k = 0 ;k < 3;k++)

for(int s = 0 ;s < 3;s++)

dp[i][j][k] += dp[i-1][j][s]*dp[1][s][k] ;

int n , s , t ;

int num ;

scanf("%d" , &num) ;

while(num--)

{

scanf("%d%d%d" ,&s , &t ,&n) ;

printf("%.3lf\n" , dp[n][s-1][t-1]) ;

}

}

return 0 ;

}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-09-29 02:22:44

hdu3722Card Game 概率dp水题的相关文章

Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题

除非特别忙,我接下来会尽可能翻译我做的每道CF题的题面! Codeforces 148D 一袋老鼠 Bag of mice | 概率DP 水题 题面 胡小兔和司公子都认为对方是垃圾. 为了决出谁才是垃圾,大哥拿来了一袋老鼠,其中有w只白老鼠和b只黑老鼠.胡小兔先抓,先抓到白老鼠的人赢. 每次学姐抓完老鼠之后,总会有另外一只老鼠从袋子里自己跑出来(这只老鼠不算任何人抓的),而胡小兔抓老鼠时则不会发生这样的事. 每次袋子里的每只老鼠被抓到的概率相等,当有一只老鼠跑出来的时候,每只老鼠跑出来的几率也相

13年山东省赛 The number of steps(概率dp水题)

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud The number of steps Time Limit: 1 Sec  Memory Limit: 128 M Description Mary stands in a strange maze, the maze looks like a triangle(the first layer have one room,the second layer have two ro

LightOJ1030 Discovering Gold 概率DP 水题

Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1.

poj 3071 Football (概率DP水题)

G - Football Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, …, 2n. In each round of the tournament, all teams

HDU 4576 Robot 概率DP 水题

Robot Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 3851    Accepted Submission(s): 1246 Problem Description Michael has a telecontrol robot. One day he put the robot on a loop with n cells.

hdu4405Aeroplane chess 概率dp水题

//从0到n有n+1个格子 //对于格子i,掷一次骰子的数为x.那么能够从位置i到位置i+x //格子之间有连线,假设格子a和b有连线,那么从a到b不用掷骰子 //求从0到n的骰子掷的次数的期望 //dp[i] = 1/6*segma(dp[k]) + 1 (i<=k<=i+6) #include<cstdio> #include<iostream> #include<cstring> using namespace std ; const int maxn

HDU 4405 Aeroplane chess 概率DP 水题

Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2327    Accepted Submission(s): 1512 Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids lab

hdu 5001 walk 概率dp入门题

Description I used to think I could be anything, but now I know that I couldn't do anything. So I started traveling. The nation looks like a connected bidirectional graph, and I am randomly walking on it. It means when I am at node i, I will travel t

URAL 1039 Anniversary Party 树形DP 水题

1039. Anniversary Party Time limit: 0.5 secondMemory limit: 8 MB Background The president of the Ural State University is going to make an 80'th Anniversary party. The university has a hierarchical structure of employees; that is, the supervisor rela