解题思路:
首先想到的是搜索,搜索使用哪几种符合条件的饲料,找最小的花费。由于dfs的特点,先找到的方案一定是字典序最小的。
但是暴力搜索会超时,需要剪枝,详见注释
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,v[35],a[35][35],ans=1e9,cnt,t,c[35],top[35];
void dfs(int x,int sum){
bool fl
解题思路:
首先想到的是搜索,搜索使用哪几种符合条件的饲料,找最小的花费。由于dfs的特点,先找到的方案一定是字典序最小的。
但是暴力搜索会超时,需要剪枝,详见注释
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m,v[35],a[35][35],ans=1e9,cnt,t,c[35],top[35];
void dfs(int x,int sum){
bool fl