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 ...
随机推荐
- USACO Milk2 区间合并
这题WA了四次,后来发现不能用所谓的桶排来写 虽然空间上是可以的,但是存在这样一个问题 比如两组数据[15,20]和[21,30] 在20 和 21这两个时刻之间没有milking,但是用桶排的方法写 ...
- iOS开发笔记--使用blend改变图片颜色
最近对Core Animation和Core Graphics的内容东西比较感兴趣,自己之前也在这块相对薄弱,趁此机会也想补习一下这块的内容,所以之后几篇可能都会是对CA和CG学习的记录的文章. 在应 ...
- python _thread模块使用
python关于线程管理的有2个类,_thread(在2.x的版本中叫thread)和threading. # encoding: UTF-8 import thread import time ...
- 如何自学 Python(干货合集)
http://wenku.baidu.com/view/5108f974192e45361066f583.html
- http 连接复用
定义 Http/1.0每次请求都需要建立新的TCP连接,连接不能复用.Http/1.1新的请求可以在上次建立的tcp连接之上发送,连接可以复用. 优点 减少重复进行tcp三次握手的开销,提高效率.注意 ...
- arm: 使用结构体操作寄存器
使用结构体操作寄存器: //寄存器赋值和取值的时候,要注意寄存器的长度,有的寄存器的值只有8位. //还要注意,使用volatile修饰寄存器变量.volatile 参考http://www.cnbl ...
- 一天一个类,一点也不累 之 LinkedList
我们的口号是,一天一个类,一点也不累 .. 今天要讲的是---LinkedList 首先,还是看看他的组织结构 Class LinkedList<E> java.lang.Object j ...
- 03-Foundation中NSMutableArray遍历、复制和排序
目录: 一.NSString补充 二.NSMutableArray可变数组 三.遍历 四.NSArray支持的新语法 五.数组复制 六.数组的排序 SDK.API.Foundation.Cocoa是什 ...
- Starting the application on Mac does not work(拷贝platforms到不同的位置,才能解决问题),还可设置DYLD_PRINT_LIBRARIES=1 观察动态库
In some rare cases it can happen that the application does not launch and there is no reaction after ...
- UIView详解1
一个UIView的实例就是一个视图,表示的是屏幕上的一块矩形区域,负责这块矩形区域的描绘以及和用户的交互. 第一.UIView的可视化属性 1. backgroundColor 背景属性 2. hi ...