2019CCPC湖南全国邀请赛(广东省赛、江苏省赛)I题 Neko and tree

这是一道来自2019CCPC湖南全国邀请赛的题目,要求在树形结构中选择关键节点,使得任意两个节点间的距离不超过k。给定树的节点数n、关键节点数m和最大距离k,求解不同的选择方式数量,并模10^9+7。输入包括树的边信息和关键节点列表,输出应为满足条件的选择方式总数。可以通过预处理树的距离并暴力枚举关键节点来解决,但时间复杂度较高。
摘要由CSDN通过智能技术生成

 

Neko and tree

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0

Problem Description

Neko has a tree with n nodes. 
There are m key nodes on tree. Neko want to you to selecte some key nodes satisfying the distance between any two selected nodes less than or equal to k. 
Neko thinks this work is too easy,so Neko want to know how many different way for selecting nodes. 
Calculate the answer after mod 109+7.
Note that you have to select at least one key node.

Input

The first line contains three integers n,m,k(1≤n,m,k≤5000). 
The next n−1 line, each line c

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值