摘要: 题意不好理解啊..以下摘自discuss已知任意一个大于1的数可以表示成一些素数的乘积,即x=p1^e1*p2^e2…… pn^en (pi 为素数,ei 为对应素数的个数),现给你x的表示,要你求x-1的 表示。 例:输入:5 1 2 1 则x=5^1*2^1=10,所以x-1=9,9可以表示成:9=3^2 输出:3 2思路:反复试除#include <stdio.h>#include <string.h>#include <math.h>const int MAXN = 33333;int prime[MAXN],num;bool is[MAXN];in 阅读全文
posted @ 2011-04-12 21:27 L.. 阅读(360) 评论(0) 推荐(0) 编辑
摘要: /*RMQ问题——稀疏表算法状态转移方程dp[i,j]=min{dp[i,j-1],dp[i+2j-1,j-1]}*/#include <stdio.h>#include <math.h>#include <stdlib.h>const int MAXN = 50001;int max[MAXN][16],min[MAXN][16]; //2^16 = 65536int a[MAXN];int n, Q;inline int getMax(int a, int b){ return a > b ? a : b;}inline int getMin(in 阅读全文
posted @ 2011-04-12 17:09 L.. 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 单调队列 见http://www.cnblogs.com/lxf90/articles/2012016.html第一,原序列的坐标单调第二,原序列的值单调/*单调队列 */#include <stdio.h>using namespace std;const int MAXN = 100001;struct dqueue{ int val; int idx;}que[MAXN];int a[MAXN], cnt;int head, tail;int lefts;int main(){ int n; //cin >> n; scanf("%d",&am 阅读全文
posted @ 2011-04-12 17:04 L.. 阅读(166) 评论(0) 推荐(0) 编辑
摘要: inline bool scan_d(int &num) // 这个就是 加速的 关键了 { char in;bool IsN=false; in=getchar(); if(in==EOF) return false; while(in!='-'&&(in<'0'||in>'9')) in=getchar(); if(in=='-'){ IsN=true;num=0;} else num=in-'0'; while(in=getchar(),in>='0' 阅读全文
posted @ 2011-04-12 16:17 L.. 阅读(146) 评论(0) 推荐(0) 编辑
摘要: /*做这题的时候是参考别人的程序现在拿出来回顾下好好理解一下这题的思路第一,这题需要离散化第二,计算矩形并的面积 当某一条线段被覆盖两次或两次以上 计算一次面积 具体的画个图比较明了第三,也是最重要的,线段数once, more的更新, 当时没有掌握到线段数的精髓 也是迷迷糊糊的,现在回来想想,once more 是第一类信息 表示当前区间的性质所有递归回来的时候 由递推关系更新once more 而more 又是由once 推出来的 */#include <stdio.h>#include <stdlib.h>#include <math.h>#defin 阅读全文
posted @ 2011-04-12 16:03 L.. 阅读(984) 评论(1) 推荐(0) 编辑
摘要: /*按照大牛博客顺序做的题目 以前离散化好好理解了下注意离散化后struct SegTree{ int l, r; int color; int getMid(){ return (l + r) >> 1; }}tree[MAXN << 2];中l,r不是原区间的坐标了,而是排序去重后数组中对应的下标做这题问题不大 基本上1A 第一次数组开小了 囧.*/#include <stdio.h>#include <stdlib.h>#include <string.h>#define L(x) ((x) << 1)#define 阅读全文
posted @ 2011-04-12 14:33 L.. 阅读(203) 评论(0) 推荐(0) 编辑
摘要: /*哈希第一题啊..! 谢谢 http://www.cnblogs.com/Dario67/archive/2011/04/09/2010724.html 的博主这题投机取巧了,判断是否相等 直接排序 比较相等 混过去了 实际题目意思不是这样的 呵呵*/#include <stdio.h>#include <stdlib.h>#define M 99991 //大素数 这是怎么来的我还不清楚#define MAXN 100000struct flake{ int arm[6]; struct flake *next; //拉链法处理冲突 void init(){ nex 阅读全文
posted @ 2011-04-12 06:09 L.. 阅读(345) 评论(0) 推荐(0) 编辑