摘要: 背景:斐波那契数列,求Fib[n] mod 2m 思想:分治法的应用,构造矩阵code 阅读全文
posted @ 2010-05-14 23:27 superbin 阅读(332) 评论(0) 推荐(1) 编辑
摘要: 二分法求幂+取模求BP mod M根据分治的思想 divide & conquer:if (P is even) BP = (BP/2)2;else BP = (BP-1)*B;将P转换成二进制后得到0-1序列,通过观察易知规律为了容易理解,先考虑 P = 2n 的情况,此时BP = B2n;即:whlie (n--){  B *= B;  }如:B=3,P = 4, 3*3 = 9, 9... 阅读全文
posted @ 2010-05-14 21:33 superbin 阅读(227) 评论(0) 推荐(1) 编辑
摘要: USACO都荒废好久了,今年都没怎么做,今天突然想做做一道搜索题,写了个很**的算法,开了9维的数组保存状态,能写成这样也不容易啊,时间复杂度可想而知,因为用的广搜,空间就更。。。一看解题报告,太伤人了,居然有O(1)的算法!我的代码来看看解题报告吧:Analysis 58: The ClocksNotice that the order in which we apply moves is ir... 阅读全文
posted @ 2010-05-14 17:37 superbin 阅读(683) 评论(0) 推荐(1) 编辑
摘要: 又一道基础题,进制转换。做水题也不能大意![代码] 阅读全文
posted @ 2010-05-14 15:50 superbin 阅读(612) 评论(0) 推荐(1) 编辑
摘要: 又一道水题[代码] 阅读全文
posted @ 2010-05-14 15:08 superbin 阅读(290) 评论(0) 推荐(1) 编辑
摘要: 无意中看到了《Art of programming contest》 UVa的,感觉不错,还发现的一个大牛的博客,里面有UVA及ragional and world final 的很多解题报告本想上去水一道题,谁知却被水了。[代码] 阅读全文
posted @ 2010-05-14 14:37 superbin 阅读(444) 评论(0) 推荐(1) 编辑