摘要:
利用点积和叉积列方程(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 阅读全文
摘要:
凸包问题,求出凸包后,计算距离,不知道为什么n==2的情况居然不是两点距离的2倍,而是正好是两点的距离。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define maxn 505struct point{ double x, y;}pnt[maxn], res[maxn];int n, m;b 阅读全文
摘要:
看是否所有定点的度都是偶数,并使用并查集看图是否连通。我开始因为没有判断是否连通而错了许多次。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1005int n, m, f[maxn], father[maxn];int getanc(int a){ if (father[a] == a) return a; return father[a] = getanc(fat 阅读全文
摘要:
求多边形面积,选定(0,0)点,用三角形法求,求三角形面积时用叉积,把式子展开并合并同类项可得模板中的公式。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 101struct XPoint{ double x, y;}point[maxn];int n;void input(){ for (int i = 0; i < n; i++) { scanf(" 阅读全文
摘要:
最短路+dfs,dfs的时候要记忆化,并记得判断能否从该点来。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define INF 0x03F3F3F3Fconst int N = 1000;int path[N], vis[N];int n, m;int cost[N][N], lowcost[N], dp[N];void input(){ scanf("%d", &a 阅读全文