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经过一段时间 ...
随机推荐
- angular-模块Module
模块定义了一个应用程序. 模块是应用程序中不同部分的容器. 模块是应用控制器的容器. 控制器通常属于一个模块. <div ng-app="myApp" runoob-dire ...
- HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException
HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException type ...
- setsockopt 设置socket
1.closesocket(一般不会立即关闭而经历TIME_WAIT的过程)后想继续重用该socket:BOOL bReuseaddr=TRUE;setsockopt(s,SOL_SOCKET ,SO ...
- C#中的CSP(Communicating sequential processes)
说起Golang(后面统称为Go),就想到他的高并发特性,在深入一些就是 Goroutine.在大家被它优雅的语法和简洁的代码实现的高并发程序所折服时,其实C#/.NET也可以很容易的做到.今天我们来 ...
- 解决linux ping: unknown host www.baidu.com
如果ping域名的时候出现ping:unknown host xxx.xxx 但是ping IP地址的时候可以通的话 可知是dns服务器没有配置好, 查看一下配置文件/etc/resolv.conf ...
- Java8内置的四大核心函数式接口
package java_8; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import j ...
- vue中响应式props办法
title: vue中响应式props办法 toc: false date: 2018-12-25 21:22:49 categories: Web tags: Vue 更新props数据时,使用th ...
- 继续ubuntu和遇到的easybcd的坑
找了很多教程,反复斟酌https://www.zhihu.com/question/34611974 个人感觉前方还有大坑无数.unbuntu四个分区系列——65%根目录,25%home目录,交换分区 ...
- Java数据库连接——jdbc-odbc桥连接方式及汉字乱码问题
jdbc-odbc桥连接方式操作数据库SU(Course),其中Course属性有Cno,Cname,Cpno,Ccredit. 步骤: 1.配置数据源 控制面板下搜索管理工具->ODBC数据源 ...
- SpringBoot学习笔记(1)----环境搭建与Hello World
简介: Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配 ...