2013年8月2日
摘要: http://projecteuler.net/problem=5Answer:232792560 阅读全文
posted @ 2013-08-02 23:18 tobec 阅读(89) 评论(0) 推荐(0) 编辑
摘要: http://projecteuler.net/problem=4答案:906609 阅读全文
posted @ 2013-08-02 23:01 tobec 阅读(97) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4614线段树 , 中间有二分操作#include #include #include #include using namespace std;#define ls (rt>1)const int maxn = 50050;struct node { int l , r; int sum; int lazy;}t[maxn mid) return query(rs,l,r); else if(r mid) change(rs , l , r , val); else if(r ... 阅读全文
posted @ 2013-08-02 17:16 tobec 阅读(186) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4628#include #include #include #include using namespace std;bool is[1=0;i--) { f[i] = (1<<29); for(int j=i+1;j<=n;j = (j+1)|i) { if(is[j-i]) { f[i] = min(f[i] , f[j] + 1); } } } printf("%d\n" , ... 阅读全文
posted @ 2013-08-02 17:13 tobec 阅读(177) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4638线段树 离线处理题意为询问一段区间里的数能组成多少段连续的数。先考虑从左往右一个数一个数添加,考虑当前添加了i-1个数的答案是x,那么添加完i个数后的答案是多少?可以看出,是根据a[i]-1和a[i]+1是否已经添加而定的,如果a[i]-1或者a[i]+1已经添加一个,则段数不变,如果都没添加则段数加1,如果都添加了则段数减1。设v[i]为加入第i个数后的改变量,那么加到第x数时的段数就是sum{v[i]}(1#include #include #include using namespace std; 阅读全文
posted @ 2013-08-02 13:58 tobec 阅读(227) 评论(0) 推荐(0) 编辑