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 ...
随机推荐
- java排序方法中的插入排序方法
插入排序方法就是:将一个数据插入到已经排好序的有序数据中,从而得到一个新的.个数加一的有序数据. package Array; //插入排序方法 import java.until.Scanner; ...
- CodeForces 519B A and B and Compilation Errors【模拟】
题目意思还是蛮简单的,看 输入数据输出数据还是比较明显的 我用排序来写还是可以AC的 //#pragma comment(linker, "/STACK:16777216") // ...
- onekey_fourLED
也许我们刚开始用到开发板的时候都会去做跑马灯的程序,后来给我们的要求是,如果硬件接口有限制,只有一个key 或者是button—— 我们的板子上是button,让你用一个button去控制这四个led ...
- windows下安装ruby和 rails的痛苦经历
准备安装ruby on rails,在网上搜了下,步骤都类似,但实际安装过程中却碰到很多问题.下面详细说下: 说明下,文章是按照我尝试的过程描述的.但最终是靠 运行 railsinstaller一键式 ...
- 在 Windows 下远程桌面连接 Linux - VNC 篇
VNC是由AT&T试验室开发,是一款优秀的远程控制工具软件,后来以GPL授权的形式开源.经过几年的发展,现在的VNC已经不单指某个软件,而是一类软件的通称.下面介绍Linux下常用的两个VNC ...
- JAVA思维导图系列:多线程0基础
感觉自己JAVA基础太差了,又一次看一遍,已思维导图的方式记录下来 多线程0基础 进程 独立性 拥有独立资源 独立的地址 无授权其它进程无法訪问 动态性 与程序的差别是:进程是动态的指令集合,而程序是 ...
- mysql之数据类型
一.概述: 所谓建表,就是声明列的过程: 数据是以文件的形式放在硬盘中(也有放在内存里的) 列:不同的列类型占的空间不一样 选列的原则:够用又不浪费: 二.mysql的数据类型: 整形:Tinyin ...
- linux查看端口和进程
查看进程 ps -aux | grep appname 杀死进程 kill pid 查看端口: netstat -ap | grep 端口号 netstat -ap | grep 进程名字 lsof ...
- Mixtile LOFT
日前,国内电子原型类开发团队Mixtile(深圳致趣科技)新推出的 Mixtile LOFT套件,受到业内著名的海外科技网站CNXSoft的关注和报道. 如果要阅读相关的原文报道,可点击这里.下面摘录 ...
- 用ATL写简单的ActiveX控件 .
我正在做的项目需要用读卡器来读数据,由于系统是B/S架构的所以只能把读卡器的驱动封装成一个无界面的ActiveX控件,这样web页面中的js代码才能访问读卡器其实做起来也挺简单的,我用的环境是VS20 ...