摘要:
跳台阶问题 一个楼梯共有 n 级台阶,每次可以走一级或者两级,问从第 0 级台阶走到第 n 级台阶一共有多少种方案。 输入格式 共一行,包含一个整数 n。 输出格式 共一行,包含一个整数,表示方案数。 1.dfs暴力解法 include using namespace std; int dfs(in 阅读全文
摘要:
01背包 include<bits/stdc++.h> using namespace std; const int MAXN = 1005; int v[MAXN]; // 体积 int w[MAXN]; // 价值 int f[MAXN][MAXN]; // f[i][j], j体积下前i个物品 阅读全文
摘要:
递归实现排列型枚举 法一: 考虑在各个位置上放哪些数字 include using namespace std; int n; const int N=20; int arr[N]; bool st[N]; void dfs(int x){ if(x>n) { for(int i=1;i<=n;i+ 阅读全文
摘要:
P2089 烤鸡 include using namespace std; int n; const int N=20; int arr[N]; int mem[59050][N]; int res=0; void dfs(int x,int sum){ if(sum>n)return; if(x> 阅读全文
摘要:
import java.util.Random; import java.util.Scanner; import java.util.Set; import java.util.HashSet; import java.util.Vector; public class Main { public 阅读全文
摘要:
递归实现组合型枚举: include include using namespace std; int n,r; const int N=30; int arr[N]; int arr1[N]; int cnt=0; bool isSu(int x){ if(x<2)return false; if 阅读全文