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 ...
随机推荐
- Visual Studio 创建和使用dll的方法
DLL是一个包含可由多个程序同时使用的代码和数据的库. DLL文件就是把一些函数导出来,然后在新程序中进行复用的过程. 第一部分:使用Visual Studio 2010进行DLL的制作 生成方法一: ...
- BZOJ 1797: [Ahoi2009]Mincut 最小割( 网络流 )
先跑网络流, 然后在残余网络tarjan缩点. 考虑一条边(u,v): 当且仅当scc[u] != scc[v], (u,v)可能出现在最小割中...然而我并不会证明 当且仅当scc[u] = scc ...
- Ural 1068 - Sum
Your task is to find the sum of all integer numbers lying between 1 and N inclusive. Input The input ...
- 编写存储过程导出oracle表数据到多个文本文件
1.测试表和数据: create table test(id )); begin .. loop insert into test values(k,'test'||k); end loop; end ...
- Java--日期的使用
Date 类: 最基础的日期时间类,返回一个相对日期的毫秒数.精确到毫秒,但不支持日期的国际化和分时区显示. Calender类: 相对于Date更加强大的时间类,是抽象类,提供了常规的日期修改功能和 ...
- Poj 2777 Count Color(线段树基础)
又毁三观了.......虽然题目数据有坑:区间[a,b]可能会有a>b的情况,但是我一开始没有考虑它也能过. 此外莫名其妙的TLE #include <iostream> #incl ...
- C#后台代码编写图片地址Properties.Resources._1;
if (i == 0) { pictureBox1.Image = Properties.Resources._1; ...
- C++逗号运算符与逗号表达式
C++将赋值表达式作为表达式的一种,使赋值操作不仅可以出现在赋值语句中,而且可以以表达式形式出现在其他语句(如输出语句.循环语句等)中.这是C++语言灵活性的一种表现. 请注意,用cout语句输出一个 ...
- 1 #安装php
#安装php #备注:php5..3以后的版本源码不需要打php-fpm补丁,该补丁已经集成进5..3中强制启用fastcgi. [root@dba01 nginx-]# cd [root@dba01 ...
- 网络授时服务 NTP
NTP --- Network Time Protocol 网络授时服务,他解决的主要问题就是实现两台或者多台机器的时间同步问题,而传统的格林尼治时间不是标准的时间,因为地球自转的不是规则的. 网络 ...