若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1538: Complete Tree labeling

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,230

题目描述

A complete k-ary tree is a k-ary tree in which all leaves have same depth and all internal nodes have degree or (equivalently) branching factor k. It is easy to determine the number of nodes of such a tree.

Given the depth and branching factor of such a tree, you must determine in how many different ways you can number the nodes of the tree so that the label of each node is less that that of its descendants. This is the property which defines the binary heap priority queue data structure for k = 2. In numbering a tree with N nodes, assume you have the labels (1, 2, 3,…, N – 1, N) available.

输入

The input file will contain several lines of input. Each line will contain two integers k and d. Here k > 0 is the branching factor of the complete k-ary tree and d > 0 is the depth of the complete k-ary tree. Your program must work for all pairs such that k x d <= 21.

输出

For each line of input, produce one line of output containing an integer counting the number of ways the k-ary tree can be labeled, maintaining the constraints described above.

样例输入

2 2
10 1


样例输出

80
3628800

参考代码

暂无

解析

暂无

hustoj

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

原站点 Dreams孤独患者 Skip
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist