码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-02-16 13:05:10      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:algorithm   codeforces   dp   快速幂   

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+快速幂)

标签:algorithm   codeforces   dp   快速幂   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!