#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. C/C++ Swap without using extra variable

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50255379 对于可以线性运算的变量, ...

  2. 杭电1596 find the safest road

    find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  3. DateForamt和SimpleDateFormat

    1.因为DateFormat是抽象类,所以只能用子类来初始化 DateFormat df = new SimpleDateFormat("yyyy--MM--dd HH:MM:ss,属于本年 ...

  4. application和javaBean练习

    编写一个jsp程序,实现将用户信息保存在application对象的用户注册 package com.sp.test; public class User { private String usena ...

  5. 关于Spring的69个面试问答——终极列表 (转)

    这篇文章总结了一些关于Spring框架的重要问题,这些问题都是你在面试或笔试过程中可能会被问到的.下次你再也不用担心你的面试了,Java Code Geeks这就帮你解答. 大多数你可能被问到的问题都 ...

  6. POJ 1990 MooFest【 树状数组 】

    题意:给出n头牛,每头牛有一个听力v,坐标x,两头牛之间的能量为max(v1,v2)*dist(v1,v2),求总的能量值 先将每头牛按照v排序,排完顺序之后,会发现有坐标比当前的x小的,会有坐标比当 ...

  7. LR编写get请求

    LR编写简单Get接口 接口必备信息:接口功能.URL.支持格式.http请求方式.请求参数.返回参数 请求地址 http://api.k780.com:88/?app=life.time 请求方式 ...

  8. js效果之导航中英文转换

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. luoguP1555 尴尬的数字(暴力+map)

    题意 题解 枚举每一个可能的二进制数.扔到一个map里 再枚举每一个可能的三进制数看map有没有就行了 反正就是很水 #include<iostream> #include<cstr ...

  10. list 分页

    package com.jsz.peini.common.util; import java.util.ArrayList; import java.util.List; public class S ...