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 ...
随机推荐
- 微信H5支付----报undened index openid
1.检查传过来的订单号是否是恒定不变的 2.检查总价是否为整数(微信要求订单金额是整数).以及不能为0 以下是这次错误的具体原因: 主要是前面读取的金额数据需要读取接口的,而不是数据库的(接口读取的是 ...
- SAS笔记(8) 利用数组重构SAS数据集
在实际应用中,我们经常会把宽数据(一个患者一条观测)转化为长数据(一个患者多条观测)或者将长数据(一个患者多条观测)转换为宽数据(一个患者一条观测),在R中我们可以利用Reshape2包来实现.在SA ...
- vimtutor总结
$vimtutor ================================================================================ W e l c o ...
- 反射实现数据库增删改查DAO及DAOImpl源代码(一)
这是DAO层,第一次尝试,如有bug希望能即使反馈,我们共同进步.具体的用法和实现原理我会在前面几篇博客中补充更新.配置文件及项目目录结构会在下一篇中贴出! package com.javasm.su ...
- InfoQ —— 百度搜索速度优化
本篇源自InfoQ —— <百度搜索速度优化> 好多名词不了解... 相关文档下载链接 背景 许霞,毕业于浙江大学.08年加入百度运维部. 本篇讲座主要讲述百度关于速度的优化,包括PC端和 ...
- NoSuchMethodError idea解决jar包冲突
报NoSuchMethodError(使用spring boot框架idea)一般是jar包冲突 Exception in thread"main" java.lang.NoSuc ...
- Linux调优(文件系统)
查看单个文件是否发生碎片化(被存在磁盘非连续磁盘块上) # filefrag -v /var/log/messages 查看文件系统是否存在大量碎片(会显示空闲离散的块) # dumpe2fs /de ...
- CF987B High School: Become Human 数学
题意翻译 题目大意 输入一个 xxx ,一个 yyy ,求是 xyx^yxy 大还是 yxy^xyx 大. (1≤x,y≤109)(1≤x,y≤10^9)(1≤x,y≤109) 输入输出格式 输入格式 ...
- shell学习(13)- vim
其中部分内容是转载的. 在命令状态下对当前行用== (连按=两次), 或对多行用n==(n是自然数)表示自动缩进从当前行起的下面n行.你可以试试把代码缩进任意打乱再用n==排版,相当于一般IDE里的c ...
- linux限制内存和磁盘使用
一.如何限制用户的磁盘空间 1. 查看系统中所有用户的磁盘空间配额 sudo repquota /dev/vda1 2. 查看某个用户的磁盘空间配额 sudo edquota user_name 要想 ...