Eequal sum sets
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesnt matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set.
#include<iostream>
using namespace std;
int a[];
int A[];
int ans=;
void dfs(int n,int cur){
if(cur==a[]){
int sum=;
for(int i=;i<a[];i++){
sum+=A[i];
}
if(sum==a[])ans++;
}
int s=;
if(cur!=)s=A[cur-]+;
for(int i=s;i<=n;i++){
A[cur]=i;
dfs(n,cur+);
}
}
int main(){
while(cin>>a[]>>a[]>>a[]&&a[]+a[]+a[]){
ans=;
dfs(a[],);
cout<<ans<<endl;
}
return ;
}
Eequal sum sets的更多相关文章
- Aizu 1335 Eequal sum sets
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set a ...
- D.6661 - Equal Sum Sets
Equal Sum Sets Let us consider sets of positive integers less than or equal to n. Note that all elem ...
- UvaLive 6661 Equal Sum Sets (DFS)
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set a ...
- UvaLive6661 Equal Sum Sets dfs或dp
UvaLive6661 PDF题目 题意:让你用1~n中k个不同的数组成s,求有多少种组法. 题解: DFS或者DP或打表. 1.DFS 由于数据范围很小,直接dfs每种组法统计个数即可. //#pr ...
- Equal Sum Sets
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=49406 题意: 输入n,k,s,求在不小于n的数中找出k个不同的数 ...
- UVALive 6661 Equal Sum Sets
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- [UVALive 6661 Equal Sum Sets] (dfs 或 dp)
题意: 求从不超过 N 的正整数其中选取 K 个不同的数字,组成和为 S 的方法数. 1 <= N <= 20 1 <= K<= 10 1 <= S <= 15 ...
- Project Euler P105:Special subset sums: testing 特殊的子集和 检验
Special subset sums: testing Let S(A) represent the sum of elements in set A of size n. We shall cal ...
- Project Euler 103:Special subset sums: optimum 特殊的子集和:最优解
Special subset sums: optimum Let S(A) represent the sum of elements in set A of size n. We shall cal ...
随机推荐
- Struts+Tomcat搭建
Struts+Tomcat搭建 tomcat使用(服务器端开发): 如果要安装Tomcat需要进行的配置:tomcat安装在c: \Tomcat CATALINA_HOME变量值设为: H:\Prog ...
- java中将list、map对象写入文件
链接地址:http://blog.sina.com.cn/s/blog_4a4f9fb50101p6jv.html 推荐:凤爪女瓜子男怪象该谁反思伦敦房价为什么持续暴涨 × wvqusrtg个 ...
- Hadoop伪分布式模式部署
Hadoop的安装有三种执行模式: 单机模式(Local (Standalone) Mode):Hadoop的默认模式,0配置.Hadoop执行在一个Java进程中.使用本地文件系统.不使用HDFS, ...
- 个人mysql配置命令
Microsoft Windows [版本 6.1.7601]版权所有 (c) 2009 Microsoft Corporation.保留所有权利. C:\Windows\system32>cd ...
- VS2013 Qt5 Mysql中文编码问题
Qt开始默认是utf-8,而VS2013默认程序编码为gb2312: 这样就会发现使用中文的时候乱码. 一般有二种解决方案: 1.在使用中文的时候,使用QTextCodec QTextCodec *g ...
- QThread 与 QObject的关系(QObject可以用于多线程,可以发送信号调用存在于其他线程的slot函数,但GUI类不可重入)
QThread 继承 QObject..它可以发送started和finished信号,也提供了一些slot函数. QObject.可以用于多线程,可以发送信号调用存在于其他线程的slot函数,也可以 ...
- android handler looper thread
在线程中调用包含创建handler方法的时候,会报错,提示: “need call Looper.prepare()” -- 在创建之前,调用Looper.prepare()方法来创建一个looper ...
- 利用java concurrent 包实现日志写数据库的并发处理
一.概述 在很多系统中,往往需要将各种操作写入数据库(比如客户端发起的操作). 最简单的做法是,封装一个公共的写日志的api,各个操作中调用该api完成自己操作日志的入库.但因为入数据库效率比较低,如 ...
- 服务列表 - Sina App Engine
服务列表 - Sina App Engine 短信服务 新浪无线短信服务是由新浪无线提供的综合性短信服务. 使用服务 下载SDK: php 服务首页 方法 新浪无线短信服务是由新浪无线提供的综合性短信 ...
- JIRA初步
JIRA 是澳大利亚 Atlassian 公司开发的一款优秀的问题跟踪管理软件工具.可以对各种类型的问题进行跟踪管理.包含缺陷.任务.需求.改进等.JIRA採用J2EE技术.可以跨平台部署.它正被广泛 ...