摘要: 这个题差不多算是记录路径的DP,题目很短,然后本来以为很水的。最近水过习惯了,竟然敲了个暴力,各种TLE,然后换了种方式水,还是水不过去,后台的k很大,所以O(k)的算法是不可能过的。这就开始纠结了,开始的时候有想过是不是DP问题,状态转移很容易发现,不过这个题目是求第k大的,然后尝试用DP写了写,挂在一个大数据了,不好检查,自己出了几个数据,检查出了BUG,如果确定了第i位为1之后,再更新的时候sum[i]数组,在最后一次改了int之后,终于过了!!! 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: kimbits 5 */ 6 #include... 阅读全文
posted @ 2012-11-19 21:16 Naix_x 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 水过啊。。直接模拟O(n^2)的算法,有O(n*logn)的算法,研究。浙大关于求N!最后非0位的阶乘模版。2012.11.22#include <cstdio>#include <cstring>#include <string>#include <cmath>#include <queue>using namespace std;int lastdigit(char* buf){ const int mod[20] = {1,1,2,6,4,2,2,4,2,8,4,4,8,4,6,8,8,6,8,2}; int len = str 阅读全文
posted @ 2012-11-19 11:11 Naix_x 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 和前边的一个题目求前缀那个很像,加上一个标记数组就行。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: contact 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <iostream> 9 #include <queue>10 #include <map>11 using namespace std;12 #define N 20000113 int dp[2000001],p[500];14 bool o[2000001];15 int 阅读全文
posted @ 2012-11-19 10:26 Naix_x 阅读(126) 评论(0) 推荐(0) 编辑