HDU 1557 权利指数 状态压缩 暴力
来源:互联网 发布:乡镇网络舆情自查报告 编辑:程序博客网 时间:2024/05/16 16:15
HDU 1557 权利指数 状态压缩 暴力
ACM
题目地址:HDU 1557 权利指数
题意:
中文题,不解释。
分析:
枚举所有集合,计算集合中的和,判断集合里面的团体是否为关键团队。
代码:
/** Author: illuz <iilluzen[at]gmail.com>* File: 1557.cpp* Create Date: 2014-06-28 14:47:58* Descripton: brute force/ set */#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int N = 20;int t, n, tot;int a[N], ans[N], sub[N], scnt;int main() {scanf("%d", &t);while (t--) {memset(ans, 0, sizeof(ans));tot = 0;scanf("%d", &n);for (int i = 0; i < n; i++) {scanf("%d", &a[i]);tot += a[i];}tot /= 2;// half total ticketsint ALL = (1 << n);// subset 1 ~ 2^n-1for (int i = 0; i < ALL; i++) {scnt = 0;// this subset's numberint tmp = i, sum = 0, no = 0;while (tmp) {if (tmp & 1) {// if no is in subsetsub[scnt++] = no;sum += a[no];}tmp >>= 1;no++;}if (sum > tot) {// if successfor (int j = 0; j < scnt; j++) {if (sum - a[sub[j]] <= tot) {// find outans[sub[j]]++;}}}}// outputprintf("%d", ans[0]);for (int i = 1; i < n; i++) {printf(" %d", ans[i]);}puts("");}return 0;}
3 0
- HDU 1557 权利指数 状态压缩 暴力
- HDU 1557 权利指数 (状态压缩)
- hdu 1557 权利指数
- hdu 1557 权利指数
- hdu 1557 权利指数
- HDU 1557 权利指数
- HDU - 1557 权利指数
- 权利指数(hdu 1557)
- hdu1557 权利指数(状态压缩)
- hdu 1557 权利指数(深搜)
- HDU-1557 权利指数(dfs)
- [DFS]HDU/HOJ 1557 权利指数 DFS枚举
- 权利指数
- HDU 逆袭指数 [暴力]
- 3690状态压缩+暴力
- hdu 1044 Collect More Jewels【暴力Bfs+状态压缩】
- HDU 4770 Lights Against Dudely 【状态压缩+暴力枚举】
- 杭电OJ题 1557 权利指数 解题报告
- 基础
- 为什么需要Spring?--Spring中的设计模式
- 一个TextView多种字体颜色,加超链接
- vim编译器下的 . 命令(点命令)
- JavaScript中面向对象那点事
- HDU 1557 权利指数 状态压缩 暴力
- noip1999(提高组) 导弹拦截
- Activity生命周期
- 浅析Apache/Tomcat/JBOSS/Nginx之区别
- 鞠们怕丝照澄攀排顾诵扑邓职倍茁
- 【KD tree】 TJU 4072 3D Birds-Shooting Game
- Java中Class类中两个值得注意的进行类型动态转换的方法
- UVA 11916 - Emoogle Grid(数论)
- 标准C程序设计(一)