会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
acm_roll
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
9
···
26
下一页
2014年10月31日
Hihocoder 1067 最近公共祖先二
摘要: 裸的LCA离线算法,存下来当模板用吧。思想就是,将所有的查询都先存起来,然后对树做一次dfs遍历,对每一次经过的节点进行染色,标记为未访问,正在访问,和已经访问完毕。可以很明显的发现如果当前点是一个查询的端点,那么如果另外一个端点正在访问,则当前点是另外一个端点的子节点,两者的LCA为另外一个端点,...
阅读全文
posted @ 2014-10-31 19:53 acm_roll
阅读(415)
评论(0)
推荐(0)
2014年10月28日
HDU 2855 Fibonacci Check-up 矩阵
摘要: 这题比较神,不看题解我是想不出来T_T证明过程如下之后直接无脑快速幂就好了。。#include #include #include #include #include #include #include #include #include #include using namespace std; ...
阅读全文
posted @ 2014-10-28 09:50 acm_roll
阅读(186)
评论(0)
推荐(0)
HDU 2276 Kiki & Little Kiki 2 矩阵
摘要: 构造出类似这样的矩阵1 0 0 11 1 0 00 1 1 00 0 1 1通过对2取模就可以模拟出开关灯的状态了。然后直接快速幂#include #include #include #include #include #include #include #include #include #inc...
阅读全文
posted @ 2014-10-28 09:47 acm_roll
阅读(134)
评论(0)
推荐(0)
HDU 3483 A Very Simple Problem 矩阵构造
摘要: 利用二项式定理,可以可以将x^k*k^x展开得x^(k-1)*(1+k-1)^x从而得到递推关系,构造出矩阵直接快速幂就好了。#include #include #include #include #include #include #include #include #include #inclu...
阅读全文
posted @ 2014-10-28 09:45 acm_roll
阅读(222)
评论(0)
推荐(0)
2014年10月25日
HDU 2807 The Shortest Path 矩阵 + Floyd
摘要: 水题, 直接模拟就可以。姿势要注意。。#include #include #include #include #include #include #include #include #include #include using namespace std; #define MP make_pair...
阅读全文
posted @ 2014-10-25 14:45 acm_roll
阅读(194)
评论(0)
推荐(0)
2014年10月24日
HDU 5015 233 Matrix 矩阵快速幂
摘要: 可以构造如下矩阵A:1 0 0 0 0 0 0 0 0 0 0 0 1 10 0 0 0 0 0 0 0 0 0 0 1 10 1 0 0 0 0 0 0 0 0 0 1 10 1 1 0 0 0 0 0 0 0 0 1 10 1 1 1 0 0 0 0 0 0 0 1 10 1 1 1 1 0 0...
阅读全文
posted @ 2014-10-24 20:50 acm_roll
阅读(184)
评论(0)
推荐(0)
ZOJ 3497 Mistwald 矩阵
摘要: 利用可达矩阵的幂来判断是否可达#include #include #include #include #include #include #include #include #include #include using namespace std; #define MP make_pair#def...
阅读全文
posted @ 2014-10-24 19:50 acm_roll
阅读(172)
评论(0)
推荐(0)
POJ 3233 Matrix Power Series 矩阵等比数列求和
摘要: 和前面有一题是一样的做法吧。A^1+A^2+A^3+A^4 = A^1+A^2+A^2*(A^1+A^2)类似这样搞就可以二分处理了。#include #include #include #include #include #include #include #include #include #i...
阅读全文
posted @ 2014-10-24 18:45 acm_roll
阅读(295)
评论(0)
推荐(0)
HDU 2157 How many ways?? 矩阵
摘要: 可达矩阵的K次幂便是从i到j走K步能到达的方案数。注意处理k=0的情况。#include #include #include #include #include #include #include #include #include #include using namespace std; #de...
阅读全文
posted @ 2014-10-24 18:23 acm_roll
阅读(189)
评论(0)
推荐(0)
HDU 1757 A Simple Math Problem 矩阵快速幂
摘要: If x = 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);对于这样一个式子,通过矩阵与线性变换的关系,可以轻松的构造出这样的矩阵A0:9 8 7 6 5 4 3 2 1 0 A1:1 1 1 1 1 1 ...
阅读全文
posted @ 2014-10-24 18:08 acm_roll
阅读(157)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
···
26
下一页
公告