SWUST OJ(963)
小偷的背包
#include<stdio.h>
#include<stdlib.h> int s, flag, n, *a; //主函数之外定义的变量为全局变量 void dfs(int index, int count, int * a)
{
if(count == s)
{
flag = ;
return;
} if (index > n)
{
return;
} dfs(index + , count + a[index], a);
dfs(index + , count, a);
} int main(int argc, char const *argv[])
{
scanf("%d",&s);
scanf("%d",&n); a = (int*)malloc(n*sizeof(int)); for (int i = ; i < n; ++i)
{
scanf("%d",&a[i]);
} dfs(, , a); if (flag)
{
printf("yes!");
}
else
{
printf("no!");
}
return ;
}
SWUST OJ(963)的更多相关文章
- [Swust OJ 404]--最小代价树(动态规划)
题目链接:http://acm.swust.edu.cn/problem/code/745255/ Time limit(ms): 1000 Memory limit(kb): 65535 Des ...
- [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)
题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...
- SWUST OJ NBA Finals(0649)
NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128 Descri ...
- [Swust OJ 1023]--Escape(带点其他状态的BFS)
解题思路:http://acm.swust.edu.cn/problem/1023/ Time limit(ms): 5000 Memory limit(kb): 65535 Descript ...
- [Swust OJ 1125]--又见GCD(数论,素数表存贮因子)
题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535 Descriptio ...
- [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)
题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...
- [Swust OJ 1026]--Egg pain's hzf
题目链接:http://acm.swust.edu.cn/problem/1026/ Time limit(ms): 3000 Memory limit(kb): 65535 hzf ...
- [Swust OJ 1139]--Coin-row problem
题目链接: http://acm.swust.edu.cn/contest/0226/problem/1139/ There is a row of n coins whose values are ...
- [Swust OJ 385]--自动写诗
题目链接:http://acm.swust.edu.cn/problem/0385/ Time limit(ms): 5000 Memory limit(kb): 65535 Descripti ...
随机推荐
- Appium下载安装及环境配置
下载地址:https://bitbucket.org/appium/appium.app/downloads/ windows安装: 下载 AppiumForWindows.zip 解压 Appium ...
- linux之more和less的基本使用
more 基本介绍 more 是我们最常用的工具之一,最常用的就是显示输出的内容,然后根据窗口的大小进行分页显示,然后还能提示文件的百分比.more命令从前向后读取文件,因此在启动时就加载整个文件. ...
- 实现mybash
任务内容 1.使用fork,exec,wait实现mybash 查找资料: fork函数 通过fork()系统调用我们可以创建一个和当前进程印象一样的新进程.我们通常将新进程称为子进程,而当前进程称为 ...
- Spring Boot事务管理(下)
在上两篇 Spring Boot事务管理(上)和Spring Boot事务管理(中)的基础上介绍注解@Transactional. 5 @Transactional属性 属性 类型 描述 value ...
- .net ML机器学习中遇见错误记录
避免入坑: 1.错误提示 numClasses must be at least 2 大概是训练模型的数据分类必须是两种,如下错误: 正确数据集如下:
- (Detected problems with API compatibility(visit g.co/dev/appcompat for more info)
在applicaiton里面加载这么一段代码: private void closeAndroidPDialog(){ try { Class aClass = Class.forName(" ...
- Python 总结
python3.7下载地址 Python安装pip 1.首先检查linux有没有安装python-pip包,直接执行 yum install python-pip 2.没有python-pip包就执行 ...
- Linux常用总结
CentOS 7.0中一个最主要的改变,就是切换到了systemd.它用于替代红帽企业版Linux前任版本中的SysV和Upstart,对系统和服务进行管理.systemd兼容SysV和Linux标准 ...
- 二、latex简单使用
安装成功则可显示如图所示的信息. 用记事本便可完成整个过程. 命令如图所示: 首先用documentclass命令引入一个文档类,比如引入article文档类,主要用于撰写论文.{}中的内容表示命令的 ...
- vue和jQuery嵌套实现异步ajax通信
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...