和 (DFS)
| Time Limit: | 1000MS | Memory Limit: | 65536KB | 
| Total Submissions: | 177 | Accepted: | 93 | 
4
1 2 4 7
13
4
1 2 4 7
15
-->
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int a[];
int vis[];
int n,m,flag;
void dfs(int i,int sum)
{
if(i<n&&!vis[i]){
vis[i]=;
if(sum+a[i]==m){
flag=;
}else if(sum+a[i]<m){
dfs(i+,sum+a[i]);
dfs(i+,sum);
}else{
dfs(i+,sum);
}
vis[i]=;
}
}
int main() {
while(cin>>n){
for(int i=;i<n;i++) cin>>a[i];
cin>>m;
flag=;
dfs(,);
if(flag) cout<<"Of course,I can!"<<endl;
else cout<<"Sorry,I can't!"<<endl;
}
return ;
}
和 (DFS)的更多相关文章
- BZOJ 3083: 遥远的国度 [树链剖分 DFS序 LCA]
		3083: 遥远的国度 Time Limit: 10 Sec Memory Limit: 1280 MBSubmit: 3127 Solved: 795[Submit][Status][Discu ... 
- BZOJ 1103: [POI2007]大都市meg [DFS序 树状数组]
		1103: [POI2007]大都市meg Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2221 Solved: 1179[Submit][Sta ... 
- BZOJ 4196: [Noi2015]软件包管理器 [树链剖分 DFS序]
		4196: [Noi2015]软件包管理器 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 1352 Solved: 780[Submit][Stat ... 
- 图的遍历(搜索)算法(深度优先算法DFS和广度优先算法BFS)
		图的遍历的定义: 从图的某个顶点出发访问遍图中所有顶点,且每个顶点仅被访问一次.(连通图与非连通图) 深度优先遍历(DFS): 1.访问指定的起始顶点: 2.若当前访问的顶点的邻接顶点有未被访问的,则 ... 
- BZOJ 2434: [Noi2011]阿狸的打字机 [AC自动机 Fail树 树状数组 DFS序]
		2434: [Noi2011]阿狸的打字机 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 2545 Solved: 1419[Submit][Sta ... 
- POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)
		来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS Memory Limit: 65536 ... 
- 深度优先搜索(DFS)
		[算法入门] 郭志伟@SYSU:raphealguo(at)qq.com 2012/05/12 1.前言 深度优先搜索(缩写DFS)有点类似广度优先搜索,也是对一个连通图进行遍历的算法.它的思想是从一 ... 
- 【BZOJ-3779】重组病毒      LinkCutTree + 线段树 + DFS序
		3779: 重组病毒 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 224 Solved: 95[Submit][Status][Discuss] ... 
- 【BZOJ-1146】网络管理Network     DFS序 + 带修主席树
		1146: [CTSC2008]网络管理Network Time Limit: 50 Sec Memory Limit: 162 MBSubmit: 3495 Solved: 1032[Submi ... 
- 【Codeforces163E】e-Government     AC自动机fail树 + DFS序 + 树状数组
		E. e-Government time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ... 
随机推荐
- Cesium高度解析
			var viewer = new Cesium.Viewer('cesiumContainer', { shadows : true }); //为true时,球体会有高程遮挡效果(在没有地形时候也会 ... 
- is not in the sudoers file解决方法
			用sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权 ... 
- go关键字之struct定义声明方式
			type Student struct{ name string age int } var stu Student stu.name,stu.age = "张三”,10 stu2 := S ... 
- sparksql udf自定义函数中参数过多问题的解决
			在进行spark sql数据库操作中,常常需要一些spark系统本身不支持的函数,如获取某一列值中的字符串. 如要获取 “aaaakkkkk”中的第4-第8个字符. 针对这种需求,只有设置UDF来实现 ... 
- css背景图撑开盒子高度
			<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ... 
- P - Air Raid
			来源poj1422 Consider a town where all the streets are one-way and each street leads from one intersect ... 
- Github Upload Large File 上传超大文件
			Github中单个文件的大小限制是100MB,为了能突破这个限制,我们需要使用Git Large File Storage这个工具,参见这个官方帖子,但是按照其给的步骤,博主未能成功上传超大文件,那么 ... 
- nginx_ssl_tomcat配置
			<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" ... 
- java第一次上机实验--验证码
			package javashiyan; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event. ... 
- 用 ArrayList  集合调用商品类
			public class Commodity{ //定义商品类 String name; //定义商品名字 double size; //定义商品尺寸 double price; //定义商品 ... 
