|
07 2012 档案
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=4087三维旋转矩阵 + 矩阵加速这个还要用到仿射变换。平移translate tx ty tz1 0 0 tx0 1 0 ty0 0 1 tz0 0 0 1缩放scale kx ky kzkx 0 0 00 ky 0 00 0 kz 00 0 0 1绕任意轴(过原点)旋转(注意要把轴向量归一化,不然会在“点在轴上”这个情况下出问题)rotate x y z d(1-cos(d))*x*x+cos(d) (1-cos(d))*x*y-sin(d)*z (1-cos(d))*x*z+sin(d)*y ...
阅读全文
摘要:题目:http://poj.org/problem?id=3845题意:给一条折线,d次分形后,求一点到初始点的距离与总长度之比刚好为 f (0<=f<=1)的位置。(一开始有点搞不明白,后来才确定就是把起始点和结束点缩放到每一条边的端点上)普通方法View Code #include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#define sqr(x) ((x)*(x))using namespace std;const int N = 110;co
阅读全文
摘要:题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3971二分答案mid,用height数组判断出现连续k次,记录出现的最大下标1,二分循环时,更新最大下标2,最后输出答案。View Code #include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 40000+100;int us[N], ua[N], ub[N], sa[N];int cmp(int *r, in
阅读全文
摘要:题目:http://www.spoj.pl/problems/PHRASES/把right[20]开成right[N],一直memset导致TLE;因为有字符串标记,所以字符串之间可以不用连接符;不过用连接符也可以。还有da(arr,n+1,256)和calheight(arr,n),注意下标。View Code #include <cstdio>#include <cstring>#include <algorithm>#define clr(a,b) memset(a,b,sizeof(a))using namespace std;const int N
阅读全文
摘要:题目:http://www.spoj.pl/problems/STONE2/用生成函数的方法,其实也是dp的思想。View Code #include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int mod = 1000000007;const int N = 105;#define M(a) ((a)%mod)#define ll long longll ans, an[N], n, all;ll t1[N*N], t2[N*N], c[N*N][N];
阅读全文
摘要:题目:http://poj.org/problem?id=3167题意:给一个模式串,按照模式串的大小对应关系,找出匹配串有相同大小对应关系的子串。利用指针,下标可以直接一一对应。View Code #include <cstdio>#include <cstring>#include <vector>using namespace std;const int N = 100000+10;const int M = 25000+10;int n, k, s, at;int a[N], b[M];int d[30], low[M], high[M], path
阅读全文
摘要:题目:http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2658ac自动机。先把单词按照题意排序,把询问串建成trie树,然后按照单词顺序进行查询,注意好结果保存,询问串可能会有重复。View Code #include <cstdio>#include <cstring>#include <string>#include <vector>#include <io
阅读全文
摘要:题目:http://poj.org/problem?id=2493View Code #include <iostream>#include <sstream>#include <cstdio>#include <map>#include <algorithm>using namespace std;const int N = 10000+10;char str[N];int main(){ //freopen("D:/a.txt", "r", stdin); int T, n, m, cas=
阅读全文
摘要:题目:http://poj.org/problem?id=3261第一道后缀数组。二分答案,然后遍历height数组,判断该答案是否出现次数大于k次。View Code #include <cstdio>#include <cstring>#include <map>using namespace std;const int N = 1000000+10;int ua[N], ub[N], us[N], n, m, arr[N], sa[N], t, cnt;int cmp(int *r,int a,int b,int l){ return r[a]==r[
阅读全文
摘要:题目:http://poj.org/problem?id=2600复数旋转+模拟退火。一开始还被复数吓到了(没学过啊),查了一下,跟坐标旋转很像啊。。。View Code #include <cstdio>#include <cmath>#include <algorithm>#define dis(a,b) sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))using namespace std;const double pi = acos(-1.0);const double eps = 1e-8;struct n
阅读全文
摘要:题目:http://poj.org/problem?id=3580View Code #include <iostream>#include <cstdio>#include <cstring>using namespace std;const int M = 300000+10;const int inf = 0x3f3f3f3f;#define type intstruct node{ int size, rev; type key, minv, delta; node *ch[2], *pre; void add(type v) { if (s...
阅读全文
摘要:题目:http://poj.org/problem?id=3285题意:求一个与三个圆的角直径都相等并且最大的点的位置。即为求一个点,使这个点到三个圆的距离与该圆的距离之比相等。用方差的方法来进行评估随机化的结果。然后注意要确保点在范围内。View Code #include <cstdio>#include <cstdlib>#include <cmath>#include <ctime>#include <algorithm>#define dis(a,b) sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(
阅读全文
摘要:题目:http://poj.org/problem?id=3301View Code #include <cstdio>#include <cmath>#include <cstring>#include <algorithm>using namespace std;const double M = 1e99;const double pi = acos(-1.0);const double eps = 1e-8;struct node{ double x, y; void get(){ scanf("%lf%lf", &am
阅读全文
摘要:题目:http://poj.org/problem?id=3608View Code #include <stdio.h>#include <math.h>#include <string.h>#include <algorithm>#define clr(a,b) memset(a,b,sizeof(a))#define sqr(x) ((x)*(x))using namespace std;const double eps = 1e-8;const double pi = acos(-1.0);const int inf = 0x3f3f3f
阅读全文
摘要:题目:http://poj.org/problem?id=2187View Code #include <iostream>#include <cstdio>#include <math.h>#include <cstring>#include <algorithm>#define sqr(x) ((x)*(x))using namespace std;const double eps = 1e-8;const int pi = acos(-1.0);const int N = 500000+10;int dcmp(double x)
阅读全文
摘要:题目:http://acm.uestc.edu.cn/problem.php?pid=1709View Code #include <stdio.h>#include <string.h>#include <iostream>#define ll long longusing namespace std;const int N = 50000+10;int M;ll a[N], n, dp[N], m;ll get_and(int y){ ll ans = 0; dp[0]=0; for (int i=1; i<=n; i++){ if ((a[i]&
阅读全文
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=1890伸展树,按照题意模拟,把所求第i个节点旋转至根节点,reverse一下View Code #include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#define keytree root->ch[1]->ch[0]using namespace std;const int M = 100000+10;const int inf = 0x3f3f3f
阅读全文
|