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的粉丝,即" ...
随机推荐
- linux 中数据库的常用操作
1-连接数据库: mysql -h localhost -u jiangbiao -p xxxxx@xxx:~$ mysql -h localhost -u jiangbiao -p Enter pa ...
- tar:short read problem
1. tar:short read problem description 在PC机上将需要下载到板子上的两个文件夹gdb.ncurses用tar命令打包. 命令如下:tar -cvf test5.t ...
- ide phpStorm更换主题
#主题下载地址 http://www.phpstorm-themes.com #更换方式 1.将主题配置保存在 xxx.icls(如果是xml也保存成.icls) 2.打开phpStorm设置(中上方 ...
- sqlmap常用命令
sqlmap也是渗透中常用的一个注入工具,其实在注入工具方面,一个sqlmap就足够用了,只要你用的熟,秒杀各种工具,只是一个便捷性问题,sql注入另一方面就是手工党了,这个就另当别论了.今天把我一直 ...
- js对重复数组去重
var arr=[1,1,1,1,2,2,2,3,3,4,1,4,5,7,8,7,7] let m = {} arr.filter(item => m[item] >= 1 ? false ...
- vue-cli3快速原型开发
先来讲一下,什么是快速原型开发. 当我们需要紧急或提前开发单独的一个页面时,有时候不需要在原项目中创建一个页面,再开发,我们可以单独的区开发这个项目,那么怎样单独的区开发这个项目呢,之前使用过vue- ...
- 最长连续子序列(dp,分而治之递归)
5227: 最大子列和问题 时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte 总提交: 76 测试通过:46 描述 给定KK个整数组 ...
- linux驱动调试记录
linux驱动调试 linux 目录 /proc 下面可以配置驱动的调试信息,比如给proc目录的自己定制的驱动的一文件设置一个变量,然后驱动程序跟了proc的参数值来配置调试级别.类似于内核调试的级 ...
- 音乐类产品——“网易云音乐”app交互原型模板(免费使用)
网易云音乐虽是一款音乐app,但有人说它也是社交界的一股清流以及一匹黑马.音乐带给人的感染,激发着很多人在这里表达着他们的情绪和心声.网易云音乐上的真实用户点评,不仅被印在地铁的广告牌上,还在朋友圈频 ...
- U盘制作系统盘的方法:
1, 使用 u 盘制作 ubuntu16.04 的方法, 安装软件后,直接使用软件将 U盘制作成系统盘就好了 [1] 下载安装工具: UltraISO 官网: http://www.ezbsyst ...