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的粉丝,即" ...
随机推荐
- AS中jar包和aar包区别及导入导出
发布时间:2018-01-18 来源:网络 上传者:用户 关键字: 导出 导入 区别 包和 aar jar 发表文章 摘要:jar包和aar包区别*.jar:只包含class文件与清单文件,不包含资源 ...
- dtIntersectSegmentPoly2D 2D上的线段与多边形相交计算 产生结果:是否相交,线段跨越的开始和结束百分比,相交的边
dtIntersectSegmentPoly2D(startPos, endPos, verts, nv, tmin, tmax, segMin, segMax): http://geomalgori ...
- 【LookLook文档】通过less 定制自己的Bootstrap 样式
闲话 学习还是看文档最快,看文档要仔细点,不可走马观花.感谢 “Bootstrap中文网” 思路 1.早在2015开始接触,由于公司中使用的是easyui 固一直没完全使用Bootstrap,开始接触 ...
- css学习_css3过渡
1.css3过渡 注意:记住多属性设置的方式:若把过渡写在了hover里面的话鼠标移走时不会有过渡效果!:不同属性同时变时用 all 就可以实现了. 2.css3 transform属性 1.移动 ...
- 生成N位数字随机数
//生成N位的随机数 全数字 private string GetRandom(int len) { string k = ""; Random rand = new Random ...
- Mybatis异常--There is no getter for property named 'XXX' in 'class java.lang.String'
第一种 在service层加@Param(value="ip") void deleteIpsetup(@Param(value="ip")String ip) ...
- 讨论mui 的 mui.init 与 mui.plusReady
先来看一段代码 (function(m, doc) { mui.plusReady(function(){ var self = plus.webview.currentWebview(); olti ...
- Django中cookie和session使用
cookie和session的简单使用 def cookie(request): """ 操作cookie """ resp = HttpR ...
- js 转java后台传过来的list
var intIndex=0; arrList = new Array(); arrList = "${orderNumList}".replace('[','').replace ...
- Yoink Mac版(临时文件存储助手)中文版
Yoink Mac版是Mac上一款临时文件存储助手,当你拖动文件时Yoink for Mac就会出现,拖放文件到Yoink窗口中即可,需要文件时随时都能从Yoink窗口中拖出文件,使用非常便捷,小编准 ...