acdream 1726 A Math game
来源:互联网 发布:兼容mac的游戏 编辑:程序博客网 时间:2024/04/29 11:56
/* ***********************************************Author :xryzEmail :xiang578@foxmail.comCreated Time :7-11 11:59:34File Name :2015_07_11.cpp************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;int a[50],h,n,use[50],sum[50],flag;void dfs(int x,int cnt){ if(cnt==h) { flag=1; return ; } if(cnt+sum[x]<h||cnt>h) return ; if(use[x]==0) { use[x]=1; dfs(x-1,cnt+a[x]); use[x]=0; } dfs(x-1,cnt); return ;}int main(){ int i; while(~scanf("%d%d",&n,&h)) { memset(a,0,sizeof(a)); memset(sum,0,sizeof(sum)); sum[0]=0; for(i=1; i<=n; i++) { scanf("%d",&a[i]); sum[i]=sum[i-1]+a[i]; } memset(use,0,sizeof(use)); flag=0; dfs(n,0); if(flag==1) printf("Yes\n"); else printf("No\n"); } return 0;}
0 0
- acdream 1726 A Math game
- acdream 1726 A Math game
- ACdream 1726A Math game
- ACdream-1726-A Math game(dfs+二分)
- ACDREAM 1726 A Math game(折半枚举+hash)
- acdream 1726 A Math game (部分和问题 DFS剪枝)
- acdream 1726 A Math game(部分和)
- A Math game
- ACdream1726-A Math game
- ACdream1726 A Math game(dfs)
- A Math game (DFS+剪枝)
- ACdream 1008 A Very Easy Triangle Counting Game 数三角形
- acdream A
- ACdream 1008 A Very Easy Triangle Counting Game(找规律)
- ACdream 1015 A
- ACdream 1726
- 10400 - Game Show Math
- uva10400 - Game Show Math
- 安全测试与渗透测试区别
- 1005. 继续(3n+1)猜想 (25)
- LeetCode Search Insert Position
- 2015湖南省队集训DAY8——梦工厂
- MyBatis(一)——mybatis入门
- acdream 1726 A Math game
- VS2010 添加OnInitDialog的方法
- C++完美实现Singleton模式
- UI-字体
- java基础——“”equals“”与 “”==“” 的区别
- css中box-shadow属性与text-shadow属性
- python 命令行参数解析
- 优化的原则
- ImageView图片自适应