博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NYOJ--927--dfs--The partial sum problem
阅读量:4310 次
发布时间:2019-06-06

本文共 753 字,大约阅读时间需要 2 分钟。

/*    Name: NYOJ--927--The partial sum problem    Author: shen_渊     Date: 15/04/17 19:41    Description: DFS,和 NYOJ--1058--dfs--部分和问题 基本一致,递归的i+1注意了,其他没什么 */#include
#include
using namespace std;void dfs(int);int arr[22],vis[22];int n,k,sum,flag;int main(){// freopen("in.txt","r",stdin); while(cin>>n){ memset(vis,0,sizeof(vis)); memset(arr,0,sizeof(arr)); flag = 0; for(int i=0; i
>arr[i]; cin>>k; dfs(0); if(flag)cout<<"Of course,I can!\n"; else cout<<"Sorry,I can't!\n"; } return 0;}void dfs(int ct){ if(sum == k){ flag = 1; return ; } for(int i=ct; i

 

转载于:https://www.cnblogs.com/evidd/p/7251882.html

你可能感兴趣的文章
Unable to launch the IIS Express Web server
查看>>
黑客与画家 第七章
查看>>
Tomcat实践
查看>>
第二次冲刺计划周第四天
查看>>
leetcode 120. Triangle
查看>>
边缘网关协议(BGP)
查看>>
github和gitlab并存
查看>>
表单日期点击输入时显示日历表
查看>>
Css中position、float和clear整理
查看>>
JavaScript表单验证
查看>>
Vijos p1123 均分纸牌
查看>>
关于NSDateFormatter的格式-dd是月天,DD是年天
查看>>
各路传奇排序
查看>>
像心跳的方向走
查看>>
收集JavaScript中常用的方法函数
查看>>
2. cgi 结构目录
查看>>
Abp框架下 Area中新建Layout报错的问题
查看>>
linux下修改hosts文件
查看>>
Restful API 设计参考原则
查看>>
两个实用的Python的装饰器
查看>>