上一页 1 ··· 158 159 160 161 162 163 164 165 166 ··· 182 下一页
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 105bool map[maxn][maxn];int test(int x, int y, int l){ int ans = 0; for (int i = x; i < x + l; i++) for (int j = y; j < y + l; j++) if (map[i][j]) ans++ 阅读全文
posted @ 2011-04-08 18:13 undefined2024 阅读(159) 评论(0) 推荐(0)
摘要: 和计算几何相关的求逆序数,我是用树状数组做的,也可以用归并排序。 注意,由于是开区间所以读入区间后要将区间向内收缩eps.这道题还比较考察浮点数的相关知识。浮点数比较a<b要写成a+eps < b.View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;#define maxn 50005#de 阅读全文
posted @ 2011-04-07 20:18 undefined2024 阅读(267) 评论(0) 推荐(0)
摘要: 题意:给出每只狗的pretty value,然后多次询问,每次输出区间[i,j](狗站成一排,从第i只到第j只)的第k小的值是多少。区间之间有交叉,但是没有完全包含。分析:先把所有区间排序,然后从左至右把每个区间用线段树维护离散化后的pretty value,即线段树的区间的意义是pretty value。每次删除在上一个区间中且不在当前区间中的节点,插入在当前区间中且不在上一个区间中的节点,使得线段树中的节点恰好为该区间内的所有节点。然后查询第k个就容易了。View Code #include <iostream>#include <cstdio>#include & 阅读全文
posted @ 2011-04-07 09:55 undefined2024 阅读(1194) 评论(0) 推荐(0)
摘要: kmp的变形,kmp算法是先将某穿和自身匹配,写出fail数组。我们只需要这个fail数组,它的最后一位存储了我们所要求的答案中的最大长度。然后每次利用fail数组向前跳转就可以得到所有答案。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <stack>using namespace std;#define maxn 400005char s[maxn];int fail[maxn];void kmp( 阅读全文
posted @ 2011-04-06 20:10 undefined2024 阅读(1119) 评论(0) 推荐(0)
摘要: 利用点积和叉积列方程(x0,y0)X (x1,y1) = sin(120)*R^2 (r为圆的半径)(x0,y0) * (x1,y1) = cos(120)*R^2结果为:x1=b*x0-a*y0;a=sin120;y1=b*y0+a*x0; b=cos120;View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;#define eps 0.0005voi 阅读全文
posted @ 2011-03-31 09:21 undefined2024 阅读(183) 评论(0) 推荐(0)
上一页 1 ··· 158 159 160 161 162 163 164 165 166 ··· 182 下一页