题目:
题意:
给出每个装备的所有信息,求在满足物抗呵魔抗的最低要求时,要花费的最小价钱
分析:
因为数据十分小,所以愉快暴力 d f s dfs dfs切掉
代码:
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define LL long long
#define LZX 100000007
inline LL read() {
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
using namespace std;
struct node{
int a,b,w;
}x[25];
int a=read(),b=read();
int n=read();
int ans;
void dfs(int i,int s1,int s2,int m)
{
if(i>n)
{
if(s1>=a&&s2>=b) ans=min(ans,m);
return;
}
dfs(i+1,s1+x[i].a,s2+x[i].b,m+x[i].w);
dfs(i+1,s1,s2,m);
return;
}
int main()
{
for(int i=1;i<=n;i++) x[i]=(node){read(),read(),read()};
ans=2147483647/3;
dfs(1,0,0,0);
cout<<ans;
return 0;
}