首页 > 其他 > 详细

codeforces 514E Darth Vader and Tree (dp+快速幂)

时间:2015-02-16 13:03:16      阅读:321      评论:0      收藏:0      [点我收藏+]
codeforces 514E Darth Vader and Tree (dp+快速幂)

题意:
有一棵树,每个节点有n个儿子,给出父亲到每个儿子的距离di,问离祖先距离不超过x的子孙有多少个(子孙包括祖先)对1e9+7取模。
限制:
1 <= n <= 1e5; 0 <= x <= 1e9; 1 <= di <= 100
思路:
因为di <= 100,所以可以用快速幂来处理这道题,
大概过程为:先用dp算出前100的答案,剩下的用快速幂来处理。


codeforces 514E Darth Vader and Tree (dp+快速幂)

原文:http://blog.csdn.net/whai362/article/details/43851385

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!