字典树
来源:互联网 发布:成濑川奈留 知乎 编辑:程序博客网 时间:2024/05/16 12:23
/*题目网址:http://acm.nyist.net/JudgeOnline/problem.php?pid=32 */#include<iostream>#include<cstdio>#include<malloc.h>using namespace std;#define manx 12struct node{ int num; node*next[manx];};int n,r,stack[20];void init(node *tree,int n){ tree->num = n; for(int i=0;i<manx;i++) tree->next[i]=NULL;}void make(node *tree,int n){ init(tree,n); for(int i=1;i<=n-1;i++){ if(tree->next[i]==NULL){ node *p = new node(); tree->next[i]=p; make(p,n-i); } }}void query(node *tree,int k){ if(k==r){ for(int i=1;i<=k;i++) printf("%d",stack[i]); printf("\n"); return ; } for(int i=1;i<manx;i++){ if(tree->next[i]==NULL) continue; stack[++k] = tree->next[i]->num; query(tree->next[i],k); k--; }}int main(){ while(cin>>n>>r){ for(int i=n;i>=1;i--){ node *tree = new node(); make(tree,i); stack[1]=tree->num; query(tree,1); } }}
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树。。
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 字典树
- 《有些事现在不做,一辈子都不会做了》(韩梅梅)
- JSP中的路径问题,重定向与转发
- 提高绩效辅导有效性的八大实战技巧<一>
- 双向链表
- 经典链表
- 字典树
- Struts1.x教程(二) Struts进阶使用
- c语言那些细节之a+1和&a+1的区别
- 面向对象的设计原则-类设计原则
- 跟踪内存分配与释放
- UI+Sql query 查询Lov对应的后台Sql
- 博弈知识汇总
- 嵌入式C/C++接口设计
- dp uva-825-Walking on the Safe Side