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 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 ;
- }
Aizu 1335 Eequal sum sets的更多相关文章
- 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 ...
随机推荐
- Android手机设置隐藏命令大全
注意:因Android版本较多,固有部分隐藏命令或不能使用 *#*#4636#*#* 显示手机信息.电池信息.电池记录.使用统计数据.WiFi 信息 *#*#7780#*#* 重设为原厂设定,不会删除 ...
- 2014多校3 Wow! Such Sequence!段树
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=4893 这个问题还真是纠结啊--好久不写线段树的题了.由于这几天学伸展树.然后认为线段树小case了. ...
- c基础知识复习
C的发展历程 C原本是为了开发UNIX操作系统而设计的语言:如此说,应该C比UNIX更早问世,而事实并非如此,最早的UNIX是由汇编写的: C语言本来是美国人开发的,解读C的声明,最好还是用英语来读: ...
- 碰撞缓冲效果的导航条 js
- Java多线程之synchronized(四)
前面几章都是在说synchronized用于对象锁,无论是修饰方法也好修饰代码块也好,然而关键字synchronized还可以应用到static静态方法上,如果这样写,那就是对当前的*.java文件所 ...
- 解决:Visual Assist X 不支持HTML、Javascript等提示
Visual Assist X 安装后,不能进行javascript hmtl提示,只有回到老版本才行.这个问题折腾了老久,才给解决了. 记录下来,以便于网友和自己使用. 问题原因: Visual A ...
- net core 静态文件
asp.net core 之静态文件目录的操作 文章前言 之前写了一篇关于模拟登录的文章,自我感觉内容不太丰富,今天的这篇文章,希望在内容上能丰富些.本人缺少写文章的经验,技术上也是新手,但我会努 ...
- AutoCAD 2014简体中文版官方正式版x86 x64下载,带注册机,永久免费使用
注册机使用说明:会有部分杀毒软件报病毒,请无视.操作步骤:1.安装Autodesk AutoCAD 20142.使用以下序列号666-69696969安装.3.产品密码为001F14.安装完成后,启动 ...
- 通过Qt样式表定制程序外观(比较通俗易懂)
1. 何为Qt样式表[喝小酒的网摘]http://blog.hehehehehe.cn/a/10270.htm2. 样式表语法基础3. 方箱模型4. 前景与背景5. 创建可缩放样式6. 控制大小7. ...
- 解决sqlite删除数据后,文件大小不变问题(VACUUM)
删除表格的全部数据: DELETE FROM [Name] 当在sqlite中删除了大量数据后,数据库文件的大小还是那样,没有变.原因是:从Sqlite删除数据后,未使用的磁盘空间被添加到一个内在的” ...