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经过一段时间 ...
随机推荐
- javascript try{}catch(e){}
<script language="javascript"> try { throw new Error(10,"asdasdasd") } ca ...
- 洛谷 P3507 [POI2010]GRA-The Minima Game
P3507 [POI2010]GRA-The Minima Game 题目描述 Alice and Bob learned the minima game, which they like very ...
- ubuntu下使用Nexus搭建Maven私服
ubuntu下使用Nexus搭建Maven私服 1.私服简介: 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件.有了私服之后,当 Maven 需要下载构件时,直接请求私服, ...
- [AngularJS]Chapter 5 与服务器交互
第八章有关于缓存的东西. [通过$http交互] 传统的AJAX请求如下 var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange ...
- Chrome插件Axure RP Extension
Chrome插件Axure RP Extension 1.将文件夹“0.6.2_0”复制到Chrome文件夹中某个位置. 2.打开Chrome,打开[设置] - [扩展程序],勾选右上角的“开发者模式 ...
- [Hibernate]Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
使用Hibernate官方文档上的下面代码进行測试时报出这个异常. org.hibernate.HibernateException: Access to DialectResolutionInfo ...
- pandaboard安装ubuntu
参照:https://wiki.ubuntu.com/ARM/OmapDesktopInstall 主要是在linux下安装,主要命令为: zcat ./ubuntu-12.04-preinstall ...
- python微框架Bottle(http)
环境: win7系统 Python2.7 一 背景和概述 眼下项目中须要加入一个激活码功能,打算单独弄一个httpserver来写. 由于之前的游戏中已经有了一套完整的激活码生成工具和验证httpse ...
- CoreData 从入门到精通(三)关联表的创建
上篇博客中讲了 CoreData 里增删改查的使用,学到这里已经可以应对简单的数据存储需求了.但是当数据模型复杂起来时,例如你的模型类中除了要存储 CoreData 里支持的数据类型外,还有一些自定义 ...
- Ubuntu下gcc安装
在Ubuntu下安装GCC和其他一些Linux系统有点不一样. 方法一: 该方法超简单:sudo apt-get build-depgcc 就上面这条命令就可以搞定 方法二:sudo apt-get ...