Josephina and RPG HDU - 4800
Recently, Josephina is busy playing a RPG named TX3. In this game, M characters are available to by selected by players. In the whole game, Josephina is most interested in the "Challenge Game" part.
The Challenge Game is a team play game. A challenger team is made up of three players, and the three characters used by players in the team are required to be different. At the beginning of the Challenge Game, the players can choose any characters combination as the start team. Then, they will fight with N AI teams one after another. There is a special rule in the Challenge Game: once the challenger team beat an AI team, they have a chance to change the current characters combination with the AI team. Anyway, the challenger team can insist on using the current team and ignore the exchange opportunity. Note that the players can only change the characters combination to the latest defeated AI team. The challenger team gets victory only if they beat all the AI teams.
Josephina is good at statistics, and she writes a table to record the winning rate between all different character combinations. She wants to know the maximum winning probability if she always chooses best strategy in the game. Can you help her?
Input
There are multiple test cases. The first line of each test case is an integer M (3 ≤ M ≤ 10), which indicates the number of characters. The following is a matrix T whose size is R × R. R equals to C(M, 3). T(i, j) indicates the winning rate of team i when it is faced with team j. We guarantee that T(i, j) + T(j, i) = 1.0. All winning rates will retain two decimal places. An integer N (1 ≤ N ≤ 10000) is given next, which indicates the number of AI teams. The following line contains N integers which are the IDs (0-based) of the AI teams. The IDs can be duplicated.
Output
For each test case, please output the maximum winning probability if Josephina uses the best strategy in the game. For each answer, an absolute error not more than 1e-6 is acceptable.
Sample Input
4
0.50 0.50 0.20 0.30
0.50 0.50 0.90 0.40
0.80 0.10 0.50 0.60
0.70 0.60 0.40 0.50
3
0 1 2
Sample Output
0.378000
题目大意就是: RPG游戏中有很多不同的角色,选择其中三个组成一支队伍,现已知每支队伍打败其他队伍的概率,然后给你一个需要打败的队伍的顺序,求打败所有队伍的最大的概率是多少。
其实就是一道概率DP的题目,换或者不换。
对需要打败的队伍进行枚举,考虑换了队伍和不换队伍两者概率大小,取最大的那种。
// Asimple
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#define INF 0x3f3f3f3f
#define debug(a) cout<<#a<<" = "<<a<<endl
#define test() cout<<"============"<<endl
#define CLS(a,v) memset(a, v, sizeof(a))
#define pas system("pause")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {-,,,,-,-,,}, dy[]={,,-,,-,,,-};
const int maxn = +;
const ll mod = ;
ll n, m, T, len, cnt, num, ans, Max, k;
//vector<int> a[maxn];
double dp[maxn];
double Map[][];
int team[maxn]; void input(){
while( scanf("%lld", &n)!=EOF) {
n = n*(n-)*(n-)/;
double res = 1.0;
for(int i=; i<n; i++) {
for(int j=; j<n; j++) {
scanf("%lf", &Map[i][j]);
}
dp[i] = 1.0;
}
scanf("%lld", &m);
for(int i=; i<m; i++) scanf("%d", &team[i]);
for(int i=; i<m; i++) {
double te = 0.0;
for(int j=; j<n; j++) {
te = max(Map[j][team[i]]*dp[j], te);
dp[j] = dp[j] * Map[j][team[i]];
}
dp[team[i]] = te;
}
printf("%.6lf\n", dp[team[m-]]);
}
// pas;
} int main() {
input();
return ;
}
Josephina and RPG HDU - 4800的更多相关文章
- 2013长沙赛区现场赛 J - Josephina and RPG
J - Josephina and RPG Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- Josephina and RPG
Josephina and RPG Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- hdu4800 Josephina and RPG 解题报告
Josephina and RPG Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题
第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...
- hdu 4800 Josephina and RPG
简单dp #include<cstdio> #define maxn 10005 #include<cstring> #include<algorithm> usi ...
- DP ZOJ 3735 Josephina and RPG
题目传送门 题意:告诉你C(m,3)个队伍相互之间的胜率,然后要你依次对战n个AI队伍,首先任选一种队伍,然后战胜一个AI后可以选择替换成AI的队伍,也可以不换,问你最后最大的胜率是多少. 分析:dp ...
- The 2013 ACM-ICPC Asia Changsha Regional Contest - J
Josephina and RPG Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge A role-playin ...
- [HDU 2068] RPG的错排 (错排问题)
RPG的错排 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2068 题目大意: 有N个人对应N个名字,然后你去把每一个名字对应到每个人,只要求答对一半 ...
- HDU 2045 不容易系列之(3)—— LELE的RPG难题(递归/动态规划)
不容易系列之(3)—— LELE的RPG难题 Problem Description 人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即" ...
随机推荐
- overflow:hidden;和clear:both;的不同点
overflow:hidden;是针对被浮动元素的父级元素,是让父级元素找回原来的高,因为浮动的元素会让父级元素的高塌陷: 而clear:both:它是在新的元素上面书写,它是让上面浮动的元素不要干扰 ...
- 电子产品使用感受之——为什么我那么喜欢2015年的11.6寸MacBook Air?
2018年Mac笔记本产品线得到了一次更新,Mac book Pro, MacBook Air更新后的Mac 产品线变得更加让人摸不着头脑,价格昂贵不说,产品分类细化到如此程度,让一个选择困难症的消费 ...
- Spring Cloud 之Eureka(一)
简介 Eureka是Spring cloud 的基本套件之一,是基于Netflix 的Eureka做的二次封装,主要是负责完成微服务架构中的服务治理功能.它是微服务架构中最为核心和基础的模块,它主要是 ...
- c# thread数线程的创建
1. 1 2 3 4 5 6 Thread thread = new Thread(new ThreadStart(getpic)); thread.Start(); private void sho ...
- NSRunLoop 在mac command line tool上的部分运用
首先RunLoop相关博客参考这篇https://blog.csdn.net/lengshengren/article/details/12905627. 最近开发了一个mac上的命令行工具,我在主线 ...
- svg合并
假如页面有多个svg图标要加载,多次加载不利,可将多个svg合并为一个加载 如下有两个svg <svg xmlns="http://www.w3.org/2000/svg" ...
- LightGBM总结
一.LightGBM介绍 LightGBM是一个梯度Boosting框架,使用基于决策树的学习算法.它可以说是分布式的,高效的,有以下优势: 1)更快的训练效率 2)低内存使用 3)更高的准确率 4) ...
- python迭代-如何实现反向迭代
如何实现反向迭代 问题举例 实现一个连续浮点数发生器FloatRange,根据给定范围(start, end)和步进值(step) 产生一系列连续的浮点数,如FloatRange(3.0, 4.0, ...
- NodeMan介绍
近年来,随着nodejs的突飞猛进,node项目数量增长迅猛,node项目完美的阐释了“开箱即用”的理念.小到创业公司,大到阿里这样的巨头,背后均有node的身影. node项目基于Chrome的V8 ...
- vue+element-ui实现表格checkbox单选
公司平台利用vue+elementui搭建前端页面,因为本人第一次使用vue也遇到了不少坑,因为我要实现的效果如下图所示 实现这种单选框,只能选择一个,但element-ui展示的是多选框,check ...