状压以后,直接暴力枚举,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(暴力)的更多相关文章

  1. Aizu 2300 Calender Colors dfs

    原题链接:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2300 题意: 给你一个图,让你生成一个完全子图.使得这个子图中每个点的最 ...

  2. 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 ...

  3. codeforces 673C C. Bear and Colors(暴力)

    题目链接: C. Bear and Colors time limit per test 2 seconds   memory limit per test 256 megabytes input s ...

  4. 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 ...

  5. 简单主机批量管理工具(这里实现了paramiko 用su切换到root用户)

    项目名:简单主机批量管理工具 一.需求 1.主机分组 2.可批量执行命令.发送文件,结果实时返回,执行格式如下 batch_run  -h h1,h2,h3   -g web_clusters,db_ ...

  6. zoj 1610 Count the Colors 线段树区间更新/暴力

    Count the Colors Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/show ...

  7. [Codeforces673C]Bear and Colors(枚举,暴力)

    题目链接:http://codeforces.com/contest/673/problem/C 题意:给一串数,不同大小的区间内出现次数最多的那个数在计数的时候会+1,问所有区间都这样计一次数,所有 ...

  8. Zoj 1610 Count the Colors (线段树+区间更新+暴力计数)

    题目大意: 有n次操作,每次都是对一根线中的一段区间进行染色(颜色并不相同),有时候后面的颜色有可能覆盖前面的颜色,问最后涂完色,能看到的颜色有几种,每种颜色有几部分? 解题思路: 这个题目建树的时候 ...

  9. [暴力搜索] POJ 3087 Shuffle'm Up

    Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10003   Accepted: 4631 Des ...

随机推荐

  1. 使用 PHPMailer 发送邮件出现诡异bug,间歇性发送失败

    场景 使用PHPMailer的SMTP发送邮件,用的是腾讯企业邮箱 smtp.exmail.qq.com 在邮箱设置里看到配置smtp方法 问题描述 本地windows开发环境发送邮件100%成功 远 ...

  2. Docker-Zerotier

    1. 拉取镜像 docker pull zerotier/zerotier-containerized 2. 生成并运行容器 docker run \ --name=zerotier-one \ -- ...

  3. Jdk升级到11引起的问题:程序包javax.xml.bind.annotation不存在

    Jdk12 都发布了, 我也下载一个玩一玩吧.刚准备要下载,发现之前已经下载了一个11, 那就11 吧,也不用太新了. 安装了jdk11,习惯性的设置了一下环境变量: JAVA_HOME=D:\too ...

  4. Flutter SDK的下载与安装步骤 (mac版)

    本月初(应该是2018年12月4日),Google在其Flutter Live 2018大会上正式发布 Flutter 1.0 版本. 当然我们不会怀疑Google团队的技术实力,但它和React N ...

  5. 关于text-overflow实现·多余字符省略·的正确打开方式

    1. 字符包裹元素要能控制宽度 2. 包裹元素中包含代码 .wrapper { ... text-overflow: ellipsis; overflow: hidden; white-space: ...

  6. [Leetcode]005. Longest Palindromic Substring

    public String longestPalindrome(String s) { int start = 0, end = 0; for (int i = 0; i < s.length( ...

  7. java 单例模式之线程安全的饿汉模式和懒汉模式

    转载博主:thankyou https://blog.csdn.net/twj13162380953/article/details/53869983 理解: 饿汉式获取实例的步骤简单所以线程更安全. ...

  8. TOMCAT调优内容

    使用NIO EndPoint connector线程数, 最大并发数 最大请求数 阻塞队列大小 jvm Xms Xmm maxMetaspace gc收集器 应用app逻辑优化:这个才是重点

  9. python_魔法方法(四):属性访问

    通常可以通过点(.)操作符的形式去访问对象的属性,也可以通过BIF适当地去访问属性,看个例子吧 >>> class A(): def __init__(self): self.x = ...

  10. java——super关键字、final关键字、throws关键字、访问控制

    super关键字: 当父类被重写之后,子类对象无法访问父类被重写的方法,super就是为了解决这个问题: 1.使用super关键字访问父类的成员变量和成员方法: super.成员变量 super.成员 ...