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…
[题目链接]:click here~~ [题目大意] 一组题目的数目(n<=15),每一个题目有对应的难度,问你选择一定的题目(大于r个且小于l个)且选择后的题目里最小难度与最大难度差不小于x,求选择方案数. [解题思路]: DFS+回溯. 先发一发比較拙的代码: #include <bits/stdc++.h> using namespace std; const int N=1e5+10; int num[N],mum[N]; int n,m,q,t,l,r; int top,ans…
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…
题目链接: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<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…
B. Preparing Olympiad Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/B Description 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…
比赛链接:http://codeforces.com/problemset/problem/550/B 给你n个数,选出来只是2个然后求他们的和在L和R的区间内,并且选出来的数中最大值和最小值的差不得小于x,求共有多少种选法 下面是dfs搜出来的; #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #define me…