随笔分类 - DFS
摘要:problem给定一个整数n和k个变换规则(一位数可变换成另一个一位数)经过任意次的变换( 0 次或多次),能产生出多少个不同整数n 55 且 33 -> 66 则能产生234、534、264、564四种数solution一共有15种操作,说明一个数能变成多个不同的...
阅读全文
摘要:problem将整数n分成k份,满足1、每份不能为空满足2、任意两种划分方案不能相同(不考虑顺序)问有多少种不同的分法n=a[i]啊,最好的结果就是都等于)。即设剩余数大小为m=n-(a[1]+a[2]+..a[i-1]),就有a[i]using namespace ...
阅读全文
摘要:problem补全9*9的数独满足每行,每列,每个3*3方格内1~9均只出现一次solution1、答案状态:我们关心数独每个位置填了什么数。我们需要在每个状态中找出没有填的位置,检查有哪些值可以填。这些可以填的值构成了向下递归的分支。(状态就是每个每个时刻的9*9数...
阅读全文
摘要:problem给出n只猫及其重量ci每辆车载重不超过w用最少的车将猫运送到山底n=ans时,显然继续下去得不到更优的方案了。codes#include#includeusing namespace std;const int maxn = 50;int n, w, a...
阅读全文
摘要:problemsolutioncodes#include#include#include#includeusing namespace std;typedef double LD;const int maxn = 55;int n, vis[maxn];LD a[ma...
阅读全文
摘要:problemsolutioncodes//Meet in the Middle#include#include#includeusing namespace std;int n, mass, ans(666), f[233];mapma; //能称出的质量->需要的...
阅读全文
摘要:problemsolutioncodes//语文题,这很好 last submit#include#includeusing namespace std;const int maxn = 3100;int n, m, a[maxn][maxn], vis[maxn]...
阅读全文
摘要:problemsolutioncodes#includeusing namespace std;int n, ans=0, c[10], e[10][10];bool ok(int pos){ for(int i = 0; i >n; for(int i ...
阅读全文
摘要:problemsolutioncodes#includeint n, A[15], isp[50], vis[50], ok = 1;bool is_prime(int x){ for(int i = 2; i < x; i++)if(x%i == 0)retu...
阅读全文
摘要:problemsolutioncodes//尝试填每个点每种颜色填过去就好啦#includeusing namespace std;int n, e[10][10];int c[10], ans;void dfs(int cur){ if(cur == n)an...
阅读全文
摘要:problemsolutioncodes//f[i][j]:以(i,j)为终点的最长路是是多少//f[i][j] = f(它四周的比他高的方块的最长路)+1#include#includeusing namespace std;const int maxn = 110...
阅读全文
摘要:problemsolutioncodes//DFS 求通块#include#includeusing namespace std;int n, m, ans;string a[100];void dfs(int x, int y){ for(int i = -1...
阅读全文
摘要:problemsolutioncodes#includeusing namespace std;int num(int x){ int s[11] = {6,2,5,5,4,5,6,3,7,6}; if(x == 0)return s[0]; int...
阅读全文
摘要:problemsolutioncodes#includeusing namespace std;int n, k, a[30], ans;int is_prime(int n){ if(n == 1 || n == 0)return 0; if(n == ...
阅读全文
摘要:problemsolutioncodes//just for test2#include#include#include#includeusing namespace std;int n, m, x, d[210], f[210][50];string s, w[20...
阅读全文
摘要:problemsolutioncodes//(如果你玩数独会怎么填呢)......启发式:把能确定的填上#includeusing namespace std;const int score[10][10]={ {0,0,0,0,0,0,0,0,0,0}, ...
阅读全文
摘要:提交: https://www.luogu.org/problemnew/show/P1019 http://codevs.cn/problem/1018/ https://vijos.org/p/1311直接搜索就好啦,几乎没什么技巧,就是状态建模会有点难想到(应该...
阅读全文