zoj_3735,dp,长沙站j题
#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题的更多相关文章
- [hdu5136]Yue Fei's Battle 2014 亚洲区域赛广州赛区J题(dp)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 现场赛的时候由于有个地方有点小问题,没有成功AC,导致与金牌失之交臂. 由于今天下 ...
- zoj 3822 Domination 概率dp 2014牡丹江站D题
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- icpc 2017北京 J题 Pangu and Stones 区间DP
#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the fi ...
- 2017Summmer_上海金马五校 F题,G题,I题,K题,J题
以下题目均自己搜 F题 A序列 一开始真的没懂题目什么意思,还以为是要连续的子串,结果发现时序列,简直智障,知道题意之后,好久没搞LIS,有点忘了,复习一波以后,直接双向LIS,处理处两个数组L和R ...
- 63. Unique Paths II(中等, 能独立做出来的DP类第二个题^^)
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- [ICPC 北京 2017 J题]HihoCoder 1636 Pangu and Stones
#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the fi ...
- 集训第五周动态规划 J题 括号匹配
Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...
- 2018ACM-ICPC亚洲区域赛南京站I题Magic Potion(网络流)
http://codeforces.com/gym/101981/attachments 题意:有n个英雄,m个敌人,k瓶药剂,给出每个英雄可以消灭的敌人的编号.每个英雄只能消灭一个敌人,但每个英雄只 ...
- 牛客寒假基础集训营 | Day1 J题—u's的影响力(水题)
Day1 J题-u's的影响力 有一天,kotori发现了一个和lovelive相似的游戏:bangdream.令她惊讶的是,这个游戏和lovelive居然是同一个公司出的! kotori经过一段时间 ...
随机推荐
- dubbo Failed to check the status of the service com.user.service.UserService. No provider available for the service
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'u ...
- Struts(19)Struts集成
Struts2 MVC架构 模型视图控制器(Model View Controller)或MVC,MVC是俗称.是一种软件设计模式,用于开发Web应用程序.模型 - 视图 - 控制器模式是由下面三个部 ...
- 匿名訪问之(一)web application级别
假设用SharePoint做一个对外开放的公共站点,比方公司展示站点.那么浏览站点的人不须要注冊和登陆.就应该能看到内容.这个时候就须要对站点开启匿名訪问. SharePoint的匿名訪问是从上而下的 ...
- Microsoft Updateclient更新
大家好, 微软Microsoft Update产品组官方博客于昨天宣布了有关最新的Windows Updateclient更新的消息.依据这则博客.微软从当日開始逐渐向全部Windows 7, ...
- HBase基本数据操作具体解释
引言 本文档參考最新(截止2014年7月16日)的官方Ref Guide.Developer API编写. 全部代码均基于"hbase 0.96.2-hadoop2"版本号编写.均 ...
- Popupwindow 显示, 其它背景变暗。 并加上点击事件 ~ (用于记录)
public class MainActivity extends Activity implements OnClickListener { protected int mScreenWidth; ...
- hdoj 2222 Keywords Search 【AC自己主动机 入门题】 【求目标串中出现了几个模式串】
Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- CoreData(数据库升级 )版本迁移-iOS App升级安装
版权声明:本文为博主原创文章,未经博主允许不得转载. 如果IOS App 使用到CoreData,并且在上一个版本上有数据库更新(新增表.字段等操作),那在覆盖安装程序时就要进行CoreData数据库 ...
- xmanager使用
Xmanager全称Netsarang Xmanager,是国外一套非常优秀的远程监控软件.在UNIX/Linux和Windows网络环境中,Xmanager是最好的连通解决方案.我推 荐大家下载En ...
- CENTOS修改操作系统字符集
[root@localhost sysconfig]# cd /etc/sysconfig/ [root@localhost sysconfig]# vi i18n 修改并保存退出(:wq) LANG ...