HDU 2616 Kill the monster 简单DFS
来源:互联网 发布:电魂网络 编辑:程序博客网 时间:2024/05/22 01:46
Kill the monster
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1186 Accepted Submission(s): 817
Problem Description
There is a mountain near yifenfei’s hometown. On the mountain lived a big monster. As a hero in hometown, yifenfei wants to kill it.
Now we know yifenfei have n spells, and the monster have m HP, when HP <= 0 meaning monster be killed. Yifenfei’s spells have different effect if used in different time. now tell you each spells’s effects , expressed (A ,M). A show the spell can cost A HP to monster in the common time. M show that when the monster’s HP <= M, using this spell can get double effect.
Input
The input contains multiple test cases.
Each test case include, first two integers n, m (2
#include <iostream>#include <cstring>using namespace std;int n,m;int Ai[10],Mi[10];int used[10];int mina;void dfs(int deep,int hp){ if(hp<=0) { if(mina>=deep) mina=deep; return; } for(int i=0;i<n;i++) { if(used[i]==1) continue; used[i]=1; if(hp<=Mi[i]) dfs(deep+1,hp-2*Ai[i]); else dfs(deep+1,hp-Ai[i]); used[i]=0; }}int main(int argc, char *argv[]){ while(cin>>n>>m) { for(int i=0;i<n;i++) cin>>Ai[i]>>Mi[i]; memset(used,0,sizeof(used)); mina=99; dfs(0,m); if(mina==99) cout<<-1<<endl; else cout<<mina<<endl; } return 0;}
- HDU 2616 Kill the monster 简单DFS
- hdu 2616 Kill the monster(DFS)
- 【DFS】hdu 2616 Kill the monster
- hdu 2616 Kill the monster(dfs)
- HDU 2616 Kill the monster (深搜DFS)
- hdu 2616 Kill the monster
- HDU 2616 Kill the monster
- HDU 2616 Kill the monster
- hdu(2616)Kill the monster
- HDU 2616 Kill the monster
- hdu 2616 Kill the monster
- HDU-2616-Kill the monster
- HDU 2616 Kill the monster
- hdu 2616 Kill the monster(简单回溯搜索)
- HDOJ 2616 Kill the monster (DFS)
- hdu 2616 Kill the monster(深搜)
- hdu 2616 Kill the monster(暴搜)
- hdu 2616 Kill the monster(dfs+最优化剪枝+迭代加深搜索)
- 方框滤波,高斯滤波,中值滤波,双边滤波,opencv实现
- C++复习笔记——初始化列表顺序
- unity shader 固定管线实例(三) 光照 自发光混合 纹理混合
- Activity的生命周期和启动模式
- Windows基础编程 -菜单
- HDU 2616 Kill the monster 简单DFS
- 从时间服务同步本地时间
- 常量字符串出现的segmentation fault(core dumped)
- java并发编程——线程异常处理\资源共享的问题\ThreadLocal
- 隔代沟通的阻碍
- BM算法
- iOS开发中自定义相册功能性能改善
- POJ 3693 Maximum Repetition Substring 后缀数组
- 安卓开发:活动的四种启动模式