Aizu 2300 Calender Colors(暴力)
状压以后,直接暴力枚举,2^20约等于1e6,而且满足bitcount = m的状态很少。
#include<bits/stdc++.h>
using namespace std;
const int maxn = +;
double x[maxn],y[maxn],z[maxn];
double d[maxn][maxn];
double squ(double x) { return x*x; }
double dist(int i,int j) { return squ(x[i]-x[j])+squ(y[i]-y[j])+squ(z[i]-z[j]); } //#define LOCAL
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
int n,m; scanf("%d%d",&n,&m);
for(int i = ; i < n; i++){
scanf("%lf%lf%lf",x+i,y+i,z+i);
}
for(int i = ; i < n; i++){
for(int j = ; j < i; j++){
d[i][j] = dist(i,j);
}
}
double ans = ;
int vc[maxn];
for(int S = (<<n)-; S>=; S--){
int c = ;
for(int i = ; i < n; i++){
if(S>>i&) vc[c++] = i;
}
if(c == m){
double sum = ;
for(int i = ; i < c; i++){
int a = vc[i];
for(int j = ; j < i; j++){
sum += d[a][vc[j]];
}
}
ans = max(ans,sum);
}
}
printf("%lf\n",ans);
return ;
}
Aizu 2300 Calender Colors(暴力)的更多相关文章
- Aizu 2300 Calender Colors dfs
原题链接:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2300 题意: 给你一个图,让你生成一个完全子图.使得这个子图中每个点的最 ...
- codeforces 351 div2 C. Bear and Colors 暴力
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 673C C. Bear and Colors(暴力)
题目链接: C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C. Bear and Colors 暴力
C. Bear and Colors 题目连接: http://www.codeforces.com/contest/673/problem/C Description Bear Limak has ...
- 简单主机批量管理工具(这里实现了paramiko 用su切换到root用户)
项目名:简单主机批量管理工具 一.需求 1.主机分组 2.可批量执行命令.发送文件,结果实时返回,执行格式如下 batch_run -h h1,h2,h3 -g web_clusters,db_ ...
- zoj 1610 Count the Colors 线段树区间更新/暴力
Count the Colors Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/show ...
- [Codeforces673C]Bear and Colors(枚举,暴力)
题目链接:http://codeforces.com/contest/673/problem/C 题意:给一串数,不同大小的区间内出现次数最多的那个数在计数的时候会+1,问所有区间都这样计一次数,所有 ...
- Zoj 1610 Count the Colors (线段树+区间更新+暴力计数)
题目大意: 有n次操作,每次都是对一根线中的一段区间进行染色(颜色并不相同),有时候后面的颜色有可能覆盖前面的颜色,问最后涂完色,能看到的颜色有几种,每种颜色有几部分? 解题思路: 这个题目建树的时候 ...
- [暴力搜索] POJ 3087 Shuffle'm Up
Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10003 Accepted: 4631 Des ...
随机推荐
- 微信小程序小结(2) ------ 自定义组件
在小程序中有模板跟组件的概念.但模板更多的用于内容的展示,更复杂的交互逻辑就没办法了.所以在小程序中也定义了一些组件来解决一些简单逻辑的功能. 但有时预定义的组件并不能满足我们的需求,这时就需要我们自 ...
- 洛谷P3792 由乃与大母神原型和偶像崇拜
P3792 由乃与大母神原型和偶像崇拜 题目背景 由乃最近没事干,去研究轻拍学去了 就是一个叫做flip flappers,轻拍翻转小膜女的番 然后研究的过程中她看到了一个叫做大母神原型的东西 大母神 ...
- ajax跨域问题解决方案(jsonp,cors)
跨域 跨域有三个条件,满足任何一个条件就是跨域 1:服务器端口不一致 2:协议不一致 3:域名不一致 解决方案: 1.jsonp 在远程服务器上设法动态的把数据装进js格式的文本代码段中,供客户端调用 ...
- JavaScript和jquery中的宽度
Javascript: 网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: document ...
- 由奇葩cookie导致服务器500来认识cookie
问题:cookie中文会导致服务器报500错误. 一:cookie的特点 1.以键值对的形式出现的,比如:a=b;b=c 2.中文的值需要转义 cookie的例子 <!DOCTYPE html& ...
- python模块之calendar方法详细介绍
calendar,是与日历相关的模块.calendar模块文件里定义了很多类型,主要有Calendar,TextCalendar以及HTMLCalendar类型.其中,Calendar是TextCal ...
- (转)centos7.4 fdisk磁盘分区 格式化 挂载
centos7.4 fdisk磁盘分区 格式化 挂载 原文:http://blog.csdn.net/capecape/article/details/78499351 1.查看系统中有多少可以识别的 ...
- Hive 基本语法操练(六):Hive 的权限控制
Hive 的权限控制 Hive从0.10可以通过元数据控制权限.但是Hive的权限控制并不是完全安全的.基本的授权方案的目的是防止用户不小心做了不合适的事情. 为了使用Hive的授权机制,有两个参数必 ...
- Spring自动注入有关的注解
Spring不但支持自己定义的@Autowired注解,还支持几个由JSR-250规范定义的注解,它们分别是@Resource.@PostConstruct以及@PreDestroy. 1,@Comp ...
- c/s和b/s的区别及实例说明【转】
B/S结构,即Browser/Server(浏览器/服务器)结构,是随着Internet技术的兴起,对C/S结构的一种变化或者改进的结构.在这种结构下,用户界面完全通过WWW浏览器实现,一部分事务逻辑 ...