
倍增
文章平均质量分 85
wybooooooooo
博客已正式搬迁至博客园 https://home.cnblogs.com/u/wyboooo/ 欢迎大家访问
展开
-
倍增
当我们想要知道从最快地从A走到B时,朴素的想法是找出任何一个点走任意步会到达的地方,但是这样太耗内存。但是实际上可以只记录走1,2,4,8,16步能到达的地方从A出发:若跳8个格子(超过B了,放弃) 若跳4个格子(超过B了,放弃) 若跳2个格子(没超过B,跳吧) 若跳1个格子(没超过B,跳吧) ...原创 2018-06-22 21:31:21 · 7079 阅读 · 0 评论 -
hdu5266 pog loves szh III 【LCA】【倍增】
Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of the tree.Then Szh choose some nodes from the tree. He wants Pog helps to find the least common ance...原创 2018-06-22 21:44:20 · 374 阅读 · 0 评论 -
poj3728The merchant 【倍增】【LCA】
There are N cities in a country, and there is one and only one simple path between each pair of cities. A merchant has chosen some paths and wants to earn as much money as possible in each path. When ...原创 2018-06-24 18:44:43 · 446 阅读 · 0 评论