题目意思就是,给你一些邮票,要组合出K面值的,优先级:组成种类尽可能多>所需邮票数尽可能少>最大面值尽可能大。如果都相等,那么就输出tie。
这题目我一开始一直在想怎么可以用一个优秀的姿势在dfs的过程中满足上述要求第筛选…发现号困难,最后看大神的题解了。心碎。
/*************************************************************************
> OS : Linux 3.2.0-60-generic #91-Ubuntu
> Author : yaolong
> Mail : dengyaolong@yeah.net
> Created Time: 2014年05月23日 星期五 07:58:23
************************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100]; //存邮票
int v[100]; //数目
int cnt[100];//用于读取时候筛选同一币值超过5的
bool is_tie,first; //是否平局,和第一次得出结果标志
int res[6]; //结果
int best_res[6]; //最佳结果,0,5两个位置分别记录多少张和多少种
int a_i; //邮票的数目
void set_res(int num,int type){
best_res[0]=num;
best_res[5]=type;
for(int i=