Strange Billboard 题目链接: http://acm.hust.edu.cn/vjudge/contest/129733#problem/A Description The marketing and public-relations department of the Czech Technical University has designed a new reconfigurable mechanical Flip-Flop Bill-Board (FFBB). The b…
B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at le…
UVA 1508 - Equipment 状态压缩 枚举子集 dfs ACM 题目地址:option=com_onlinejudge&Itemid=8&category=457&page=show_problem&problem=4254" target="_blank" style="color:rgb(0,136,204); text-decoration:none">UVA 1508 - Equipment--P…
/* 看别人的的思路 搜索搜不出来我太挫了 状态压缩枚举+好的位置 */ #include<stdio.h> #include<string.h> #define N 20 int lower[N]; char s[N]; int len; int judge(int deng,int l,int r) { int i,f1,f2; int sum1,sum2; f1=s[0]-'0'; sum1=0; for(i=1;i<deng;i++) {//根据状态求出左边的所有和…
题目传送门 /* 题意:问最少翻转几次使得棋子都变白,输出翻转的位置 状态压缩+枚举:和之前UVA_11464差不多,枚举第一行,可以从上一行的状态知道当前是否必须翻转 */ #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN][MAXN]; int b[MAXN][MAXN]; in…
题目传送门 /* 题意:求最少改变多少个0成1,使得每一个元素四周的和为偶数 状态压缩+枚举:枚举第一行的所有可能(1<<n),下一行完全能够由上一行递推出来,b数组保存该位置需要填什么 最后检查不同的数量,取最小值 */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN…
题目链接:UVA 811 Description Once upon a time, in a faraway land, there lived a king. This king owned a small collection of rare and valuable trees, which had been gathered by his ancestors on their travels. To protect his trees from thieves, the king or…
题目链接:https://www.luogu.com.cn/problem/P1036 题目描述 已知 \(n\) 个整数 \(x_1,x_2,-,x_n\) ,以及 \(1\) 个整数 \(k(k<n)\) . 从 \(n\) 个整数中任选 \(k\) 个整数相加,可分别得到一系列的和. 例如当 \(n=4,k=3\) , \(4\) 个整数分别为 \(3,7,12,19\) 时,可得全部的组合与它们的和为: \(3+7+12=22\) \(3+7+19=29\) \(7+12+19=38\)…
思路: 直接状态压缩暴力枚举 #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #define Maxn 30 #define inf 10000000 using namespace std; int ans,n,m; int c,d; int map[Maxn][Maxn]; int lis[Maxn],node[Maxn]; <<],sum[&…
题目网址: http://acm.hdu.edu.cn/showproblem.php?pid=6077 思路: 先预处理一下,将每个数字块的“X”看作1,“.”看作0,进行状态压缩转换成二进制数,用数组保存.再遍历每个块点的元素,枚举0-9看是否符合当前位数. 代码: #include <cstdio> #include <cstring> #include <cmath> typedef long long ll; using namespace std; ][];…