hdu 2566 统计硬币 dfs 不能排除组合重复的情况 代码不完整
2016-01-09 16:18
393 查看
#include<iostream> #include<math.h> #include<cstring> #include<cstdio> using namespace std; int n,m; int count; int num[4]={0,1,2,5}; void dfs(int sum,int cnt) { int x; int i; if(cnt>n||sum>m||(cnt==n&&sum<m)||(cnt<n&&sum==m))// return ; if(cnt==n&&sum==m) { count++; } for(i=1;i<=3;i++)// { x=sum+num[i]; if(x<=m&&cnt<=n) { dfs(x,cnt+1); } } return ; } int main() { int t; while(cin>>t)// { while(t--)// { cin>>n>>m; int cnt=0; int sum=0; count=0; dfs(sum,cnt);// cout<<count<<endl; } } return 0; }
相关文章推荐
- ueditor整合struts2图片无法上传问题
- python运维笔记第一节
- PHP学习练手(十三)
- springmvc之redirect重定向
- spark Mllib基本功系列编程入门之 SVM实现分类
- PHP数组相加和merge的区别
- SpringMVC框架中多数据源的配置问题、datasource
- WebGoat实验之Cross-Site Scripting(XSS,跨站脚本攻击)- 2016.01.09
- javaEE开发中使用session同步和token机制来防止并发重复提交
- Ubuntu jdk安装及环境配置
- php class类的用法详细总结
- 实践中的importPoint
- PHP表单验证的3个函数ISSET()、empty()、is_numeric()的使用方法
- spring mvc 上传图片
- java操作Properties属性文件及获取项目部署服务器路径
- ubuntu14.04 server python3 安装matplotlib失败及解决方法
- myeclipse安装插件phpeclipse后进行PHP代码编写
- myeclipse安装插件phpeclipse后进行PHP代码编写
- asp.net MVC5 知识点一
- springmvc之接收model类