#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
double a[10010][150];
double dp[10010][150];
int b[10010];
int n;
void solve(int cnt)
{
memset(dp,0,sizeof(dp));
for(int i=0;i<cnt;i++)
dp[0][i]=1;
for(int i=1;i<=n;i++)
for(int j=0;j<cnt;j++)
{
dp[i][j]=max(dp[i][j],dp[i-1][j]*a[j][b[i]]);
dp[i][b[i]]=max(dp[i][b[i]],dp[i-1][j]*a[j][b[i]]);
}
double cur=0;
for(int i=0;i<cnt;i++)
if(dp[n][i]>cur)
cur=dp[n][i];
printf("%.6f\n",cur);
//for(int i=0;i<=n;i++)
//{
// for(int j=0;j<cnt;j++)
// cout<<dp[i][j]<<" ";
// cout<<endl;
//}
}
int main()
{
int m;
while(cin>>m)
{
int cnt=1,cur=1;
for(int i=4;i<=m;i++)
cnt*=i;
for(int i=1;i<=m-3;i++)
cur*=i;
cnt=cnt/cur;
//cout<<cnt<<endl;
for(int i=0;i<cnt;i++)
for(int j=0;j<cnt;j++)
cin>>a[i][j];
//int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>b[i];
solve(cnt);
}
return 0;
}

zoj_3735,dp,长沙站j题的更多相关文章

  1. [hdu5136]Yue Fei's Battle 2014 亚洲区域赛广州赛区J题(dp)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 现场赛的时候由于有个地方有点小问题,没有成功AC,导致与金牌失之交臂. 由于今天下 ...

  2. zoj 3822 Domination 概率dp 2014牡丹江站D题

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  3. icpc 2017北京 J题 Pangu and Stones 区间DP

    #1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the fi ...

  4. 2017Summmer_上海金马五校 F题,G题,I题,K题,J题

    以下题目均自己搜 F题  A序列 一开始真的没懂题目什么意思,还以为是要连续的子串,结果发现时序列,简直智障,知道题意之后,好久没搞LIS,有点忘了,复习一波以后,直接双向LIS,处理处两个数组L和R ...

  5. 63. Unique Paths II(中等, 能独立做出来的DP类第二个题^^)

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  6. [ICPC 北京 2017 J题]HihoCoder 1636 Pangu and Stones

    #1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the fi ...

  7. 集训第五周动态规划 J题 括号匹配

    Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...

  8. 2018ACM-ICPC亚洲区域赛南京站I题Magic Potion(网络流)

    http://codeforces.com/gym/101981/attachments 题意:有n个英雄,m个敌人,k瓶药剂,给出每个英雄可以消灭的敌人的编号.每个英雄只能消灭一个敌人,但每个英雄只 ...

  9. 牛客寒假基础集训营 | Day1 J题—u's的影响力(水题)

    Day1 J题-u's的影响力 有一天,kotori发现了一个和lovelive相似的游戏:bangdream.令她惊讶的是,这个游戏和lovelive居然是同一个公司出的! kotori经过一段时间 ...

随机推荐

  1. if判断语句

     6)if判断语句   if ... then   else   end if;     if ... then   elsif ... then   elsif ... then   else   ...

  2. 数字签名技术与https

    1,非对称加密技术 非对称加密算法需要两个密钥,公开密钥(publickey)和私有密钥(privatekey):公钥和私钥是成对出现的. 非对称加密例子:B想把一段信息传给A,步骤:1)A把公钥传给 ...

  3. Sublime Text 3 Package Control安装

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50618314 安装好Sublime T ...

  4. MQTT学习

    http://blog.csdn.net/mzwhhwj/article/details/77489890

  5. LeetCode OJ 之 Number of Digit One (数字1的个数)

    题目: Given an integer n, count the total number of digit 1 appearing in all non-negative integers les ...

  6. 实战:percona-xtrabackup 2.1.9 for mysql 5.6.19

    ----1.编译安装percona-xtrabackup yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr ...

  7. Android开发之使用Web Service进行网络编程

    使用Web Service进行网络编程 Android应用通常都是执行在手机平台上.手机系统的硬件资源是有限的,无论是存储能力还是计算能力都有限.在Android系统上开发.执行一些单用户.小型应用是 ...

  8. IBM AppScan官方帮助文档错别字缺陷,IBM的測试人员也太粗心了吧

    袁术=元素?

  9. world 替换+正则表达式命令

    打开替换命令,点击“更多”,勾选上“通配符”,正则表达式才会起作用

  10. Linux mount挂载umount卸载

    mount/umount挂载/卸载 对于Linux用户来讲,不论有几个分区,分别分给哪一个目录使用,它总归就是一个根目录.一个独立且唯一的文件结构 Linux中每个分区都是用来组成整个文件系统的一部分 ...