UESTC_The Most Wonderful Competition CDOJ 56
The Most Wonderful Competition
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Last week, School of Applied Mathematics held a competition of flying kite, contestants are divided into pairs, and one contestant competes with another in each pair. As we know, different way dividing pairs may bring different splendid level value, which appears as a real numbers. Now Miss Ye wants to know how to divide the competitor in order to attain maximum splendid level.
Input
The first line of the input contains one integer T, which indicate the number of test case.
For each test case, in the first line there is an integer N (N≤16, N is always an even number) indicating there are N contestants taking part the competition.
In the next N line, each line contains N real numbers. The j-th number in the i-th line is the splendid level value when the i-th contestant and the j-th constant are made in one pair. You can assume the j-th number in the i-th line is equal to the i-th number in the j-th line.
Output
For each case, output the maximum total splendid level value accurate to two digits after the radix point.
Sample input and output
| Sample Input | Sample Output |
|---|---|
1 |
1 |
Source
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std;
const int maxn = + ;
double value[maxn][maxn];
double f[ << ];
bool arrive[<<];
int n;
double ans; double dfs(int cur,int val)
{
if (arrive[val])
return f[val];
arrive[val] = true;
double &ans = f[val] = -1e100;
if (val)
{
for(int i = ; i < n ; ++ i)
if (val >> i & && i != cur)
{
int next = ;
int newval = val;
newval &= ~( << i);
newval &= ~( << cur);
for(int j = ; j < n ; ++ j)
if (newval >> j & )
{
next = j;
break;
}
ans = max(ans,dfs(next,newval) + value[cur][i] );
}
}
else
ans = ;
return ans;
} int main(int argc,char *argv[])
{
int Case;
scanf("%d",&Case);
while(Case--)
{
memset(arrive,false,sizeof(arrive));
scanf("%d",&n);
for(int i = ; i < n ; ++ i)
for(int j = ; j < n ; ++ j)
scanf("%lf",&value[i][j]);
dfs(,(<<n)-);
printf("%.2lf\n",f[(<<n)-]);
}
return ;
}
UESTC_The Most Wonderful Competition CDOJ 56的更多相关文章
- Kaggle Competition Past Solutions
Kaggle Competition Past Solutions We learn more from code, and from great code. Not necessarily alwa ...
- Gradient Boosting, Decision Trees and XGBoost with CUDA ——GPU加速5-6倍
xgboost的可以参考:https://xgboost.readthedocs.io/en/latest/gpu/index.html 整体看加速5-6倍的样子. Gradient Boosting ...
- 1198 - Karate Competition
1198 - Karate Competition PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...
- 编写高质量代码:改善Java程序的151个建议(第4章:字符串___建议56~59)
建议56:自由选择字符串拼接方法 对一个字符串拼接有三种方法:加号.concat方法及StringBuilder(或StringBuffer ,由于StringBuffer的方法与StringBuil ...
- 推荐一个iOS关于颜色的库-Wonderful
Wonderful 这个库主要是与UIColor息息相连的,其中一共包含四个子文件,UIColor+Wonderful,UIColor+Separate,SXColorGradientView,SXM ...
- ASProtect注册码使用教程|ASProtect SKE(加壳脱壳工具) 2.56 汉化注册版
ASProtect 是功能非常完善的加壳.加密保护工具.能够在对软件加壳的同时进行各种保护.如:反调试跟踪.自校验及用密钥加密保护等:还有多种限制使用措施,如:使用天数限制.次数限制及对应的注册提醒信 ...
- 56相册视频(土豆相册视频 激动相册视频 QQ动感影集等)——下载教程
由于目前流行的相册视频或影集大多是由Flash.音乐和图片组合而成的动画,不属于完整视频,所以不能用常规的解析方法下载. 鉴于很多朋友希望可以下载自己精心制作的相册,故在本教程中,我们将以图文并茂的方 ...
- cdoj 1489 老司机采花
地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others) M ...
- A Regularized Competition Model for Question Diffi culty Estimation in Community Question Answering Services-20160520
1.Information publication:EMNLP 2014 author:Jing Liu(在前一篇sigir基础上,拓展模型的论文) 2.What 衡量CQA中问题的困难程度,提出从两 ...
随机推荐
- Google的Protocol Buffer格式分析
[转]转自:序列化笔记之一:Google的Protocol Buffer格式分析 从公开介绍来看,ProtocolBuffer(PB)是google 的一种数据交换的格式,它独立于语言,独立于平台.作 ...
- Chosen 基本使用
点击下载Chosen 引入文件 chosen.css jquery-1.7.1.min.js chosen.jquery.js 绑定数据: for (var i = 0; i < data.le ...
- JAVA读、写EXCEL文件
採用jxl.jar包,网上下载,百度一下到出都是.希望能够帮助到大家. 接下来直接贴代码: <span style="font-size:18px;"> public ...
- hdu 2825 Wireless Password(ac自己主动机&dp)
Wireless Password Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- boost库在工作(39)网络UDP异步服务端之九
前面创建的UDP服务器和客户端,都是同步的方式,也就是说当接收数据时,不能参与别的事情执行的.如果在一个只有界面线程的程序里,又不想创建多线程,导致复杂程度的增加,在这种情况之下,我们还有一个方案可以 ...
- poj1562--Oil Deposits
Description The GeoSurvComp geologic survey company is responsible for detecting underground oil dep ...
- Git 推送分支
1.推送本地分支到远程: git push origin master 推送本地分支 master 到 远程的 origin 上面 git push origin test 将本地分支test推 ...
- JavaBean和EJB的区别
首先,EJB是指运行在EJB容器中的JavaBean.Tomcat是Web容器的参考实现.一个完整的JavaEE服务器应该包括Web容器和EJB容器.其次,Web容器中无法运行EJB,同时所有的Jav ...
- C#利用QrCode.Net生成二维码(Qr码)
在网上很多应用都是用二维码来分享网址或者其它的信息.尤其在移动领域,二维码更是有很大的应用场景.因为项目的需要,需要在网站中增加一个生成二维码分析网址的功能,在谷歌大幅度抽筋的情况下无奈使用百度.百度 ...
- PHP学习笔记三十【final】
<?php //final不能去修饰属性(变量) //如果希望类不希望被继承就可以使用final关键字 final class Person() { public function sayHi( ...