bupt summer training for 16 #2 ——计算几何
https://vjudge.net/contest/171368#overview
A.一个签到题,用叉积来判断一个点在一条线的哪个方向
可以二分,数据范围允许暴力
1 #include <cstdio> 2 3 struct point { 4 int x, y; 5 }a[5010]; 6 7 int n, m, x[2], y[2], c[5010]; 8 9 int _cross(const point &A, const point &B) { 10 return A.x * B.y - A.y * B.x; 11 } 12 13 int main() { 14 while(scanf("%d %d %d %d %d %d", &n, &m, &x[0], &y[0], &x[1], &y[1]) != EOF) { 15 if(n == 0) break; 16 c[0] = 0; 17 for(int i = 1;i <= n;i ++) 18 scanf("%d %d", &a[i].x, &a[i].y), c[i] = 0; 19 for(int X, Y, l, r, mid, ans, i = 1;i <= m;i ++) { 20 scanf("%d %d", &X, &Y); 21 if(_cross((point){a[1].x - a[1].y, y[0] - y[1]}, (point){X - a[1].y, Y - y[1]}) > 0) c[0] ++; 22 else { 23 l = 1, r = n; 24 while(l <= r) { 25 mid = (l + r) >> 1; 26 if(_cross((point){a[mid].x - a[mid].y, y[0] - y[1]}, (point){X - a[mid].y, Y - y[1]}) < 0) ans = mid, l = mid + 1; 27 else r = mid - 1; 28 } 29 c[ans] ++; 30 } 31 } 32 for(int i = 0;i <= n;i ++) 33 printf("%d: %d\n", i, c[i]); 34 puts(""); 35 } 36 }
B.横边和竖边都与对角线等价,很容易猜到最终的最优路线有等价变形
我们把所有边都等价为斜边,就会得到一个矩形
矩形四条边的斜率绝对值都为1
纵截距可以比较得到
可以发现我们要求的所谓周长
其实等价于最左边点和最右边点的横坐标之差
(或者最上边点与最下面点的纵坐标之差,这俩是相等的)
两个点的横坐标可以用直线联立得到
需要向外拓宽,+4即可
于是就得到了一个很简单又很妙的解法
1 n = input() 2 a = b = c = d = -6666666 3 for i in range(n): 4 x, y = map(int, raw_input().split()) 5 a = max(a, x + y) 6 b = max(b, x - y) 7 c = max(c, y - x) 8 d = max(d, - x - y) 9 print a + b + c + d + 4
还有一个没有发现等价的凸包做法
凸包做法作重要的就是如何处理向外拓展
有一个思路就是每个点都拆成上下左右4个点
对这 4*n 个点做凸包再求周长
重点就是点的坐标到1e6,叉积的话,要开long long啊朋友!
1 #include <cstdio> 2 #include <algorithm> 3 4 using std::max; 5 6 const int maxn = 400010; 7 8 typedef long long ll; 9 10 struct point { 11 ll x, y; 12 bool operator < (const point &a) const { 13 if(x != a.x) return x < a.x; 14 return y < a.y; 15 } 16 point operator - (const point &a) const { 17 return (point){x - a.x, y - a.y}; 18 } 19 }p[maxn], q[maxn]; 20 21 int abs(int x, int y) { 22 return x > y ? x - y : y - x; 23 } 24 25 int dis(const point &a, const point &b) { 26 return max(abs(a.x - b.x), abs(a.y - b.y)); 27 } 28 29 ll _cross(const point &a, const point &b) { 30 return a.x * b.y - a.y * b.x; 31 } 32 33 int n0, n, N; 34 35 long long ans; 36 37 int convexhull() { 38 int m = 0; 39 std::sort(p, p + n); 40 for(int i = 0;i < n;i ++) { 41 while(m > 1 && _cross(q[m - 1] - q[m - 2], p[i] - q[m - 2]) <= 0) m --; 42 q[m ++] = p[i]; 43 } 44 for(int k = m, i = n - 2;i >= 0;i --) { 45 while(m > k && _cross(q[m - 1] - q[m - 2], p[i] - q[m - 2]) <= 0) m --; 46 q[m ++] = p[i]; 47 } 48 return m - 1; 49 } 50 51 int main() { 52 scanf("%d", &n0); 53 for(int x, y, i = 0;i < n0;i ++) { 54 scanf("%d %d", &x, &y); 55 p[n ++] = (point){x + 1, y}; 56 p[n ++] = (point){x - 1, y}; 57 p[n ++] = (point){x, y + 1}; 58 p[n ++] = (point){x, y - 1}; 59 } 60 N = convexhull(), q[N] = q[0]; 61 for(int i = 1;i <= N;i ++) ans += dis(q[i], q[i - 1]); 62 printf("%lld", ans); 63 return 0; 64 }
C.非常没意思的签到题,水了发Java
发现大多OJ(cf除外)都会要求Java的public类名必须为Main
1 import java.util.Scanner; 2 3 public class Main { 4 public static void main(String []args) { 5 Scanner input = new Scanner(System.in); 6 double c, a, i; 7 String s; 8 while(true) { 9 c = input.nextDouble(); 10 if(c == 0.0) break; 11 for(i = 1, a = 0;;i ++) { 12 a += 1 / (i + 1); 13 if(a >= c) { 14 s = String.format("%.0f", i); 15 System.out.println(s + " card(s)"); 16 break; 17 } 18 } 19 } 20 } 21 }
D.反正就是枚举所有球算出能否接触
需要的时间最短的就是会碰到的那个
重点在于如何求出反射后的方向向量
求向量a关于向量b的对称向量a'的话
可以利用一个性质
假设c为a在b上的投影向量
那有a + a' = 2c
c = ab / b.length / b.length * b
原题OJ挂了评测结果未知,先把Java代码放上来
1 import java.util.Scanner; 2 3 public class D { 4 static double sqr(double x) { 5 return x * x; 6 } 7 static class point { 8 double x, y, z; 9 point() { 10 x = y = z = 0; 11 } 12 point(double x_, double y_, double z_) { 13 x = x_; 14 y = y_; 15 z = z_; 16 } 17 point(point a) { 18 x = a.x; 19 y = a.y; 20 z = a.z; 21 } 22 }; 23 static class circle extends point{ 24 double r; 25 circle() { 26 x = y = r = z = 0; 27 } 28 }; 29 static double length(point a) { 30 return Math.sqrt(sqr(a.x) + sqr(a.y) + sqr(a.z)); 31 } 32 public static void main(String []args) { 33 Scanner input = new Scanner(System.in); 34 int t, n = input.nextInt(); 35 point s = new point(); 36 point d = new point(); 37 point tmp = new point(), nex = new point(); 38 circle[] a = new circle[100]; 39 for(int i = 1;i <= n;i ++) { 40 a[i] = new circle(); 41 a[i].x = input.nextDouble(); 42 a[i].y = input.nextDouble(); 43 a[i].z = input.nextDouble(); 44 a[i].r = input.nextDouble(); 45 } 46 s.x = input.nextDouble(); 47 s.y = input.nextDouble(); 48 s.z = input.nextDouble(); 49 d.x = input.nextDouble(); 50 d.y = input.nextDouble(); 51 d.z = input.nextDouble(); 52 double A = sqr(d.x) + sqr(d.y) + sqr(d.z), B, C, test; 53 double x, x1, x2, dis; 54 int last = -1; 55 for(int k = 1;;k ++) { 56 if(k > 10) { 57 System.out.println("etc."); 58 break; 59 } 60 t = -1; 61 dis = 0.0; 62 for(int i = 1;i <= n;i ++) { 63 if(i == last) continue; 64 B = (d.x * (s.x - a[i].x) + d.y * (s.y - a[i].y) + d.z * (s.z - a[i].z)) * 2; 65 C = sqr(s.x - a[i].x) + sqr(s.y - a[i].y) + sqr(s.z - a[i].z) - sqr(a[i].r); 66 test = sqr(B) - A * C * 4; 67 if(test < 0) continue; 68 else { 69 x1 = (Math.sqrt(test) - B) / (A * 2); 70 x2 = (-Math.sqrt(test) - B) / (A * 2); 71 if(x1 < 0 && x2 < 0) continue; 72 else { 73 if(x2 >= 0) x = x2; 74 else x = x1; 75 if(x < dis || t == -1) { 76 t = i; 77 dis = x; 78 tmp = new point(s.x + d.x * x, s.y + d.y * x, s.z + d.z * x); 79 point tmp1 = new point(tmp.x - d.x - a[i].x, tmp.y - d.y - a[i].y, tmp.z - d.z - a[i].z); 80 point tmp2 = new point(tmp.x - a[i].x, tmp.y - a[i].y, tmp.z - a[i].z); 81 double tmp3 = (tmp1.x * tmp2.x + tmp1.y * tmp2.y + tmp1.z * tmp2.z) / length(tmp2) / length(tmp2); 82 nex = new point(tmp3 * tmp2.x * 2 - tmp1.x - tmp2.x, tmp3 * tmp2.y * 2 - tmp1.y - tmp2.y, tmp3 * tmp2.z * 2 - tmp1.z - tmp2.z); 83 } 84 } 85 } 86 } 87 if(t == -1) break; 88 System.out.printf("%d ", t); 89 last = t; 90 s = new point(tmp); 91 d = new point(nex); 92 } 93 } 94 }
E.这个题...数学方法无从下手
我们可以考虑二分...考虑二分的重点在于
先观察是否满足单调性再看能不能写出judge函数
因为单调性决定了能我们是否应该坚持考虑如何写judge
先确定其中一个圆的半径
再根据与两边和第一个圆相切求另外两圆半径
再判断两圆相切相离相交
单调性是显而易见的,第一个圆半径太大,另外两圆相离
太小则相交
精度正常比要求小数位高2-4位就差不多
二分左边界为0,右边界我开的是内切圆半径
(推得式子太长了,所以写的也又臭又长)
1 import java.util.Scanner; 2 3 public class E { 4 static class point { 5 double x, y; 6 point() { 7 x = y = 0; 8 } 9 point(double x_, double y_) { 10 x = x_; 11 y = y_; 12 } 13 }; 14 static final double pi = Math.acos(-1.0); 15 static final double eps = 1e-10; 16 static point[] p = new point[3]; 17 static point dec(point a, point b) { 18 return new point(a.x - b.x, a.y - b.y); 19 } 20 static point inc(point a, point b) { 21 return new point(a.x + b.x, a.y + b.y); 22 } 23 static double dot(point a, point b) { 24 return a.x * b.x + a.y * b.y; 25 } 26 static double sqr(double x) { 27 return x * x; 28 } 29 static double length(point a) { 30 return Math.sqrt(dot(a, a)); 31 } 32 static point unitp(point a) { 33 double len = length(a); 34 return new point(a.x / len, a.y / len); 35 } 36 static double cross(point a, point b) { 37 return a.x * b.y - a.y * b.x; 38 } 39 static double calc(double A, double B, double C) { 40 double test = sqr(B) - A * C * 4; 41 if(test < 0) return -1; 42 test = Math.sqrt(test); 43 double x1 = (- B + test) / (A * 2); 44 double x2 = (- B - test) / (A * 2); 45 if(x1 > 0) return x1; 46 if(x2 > 0) return x2; 47 return -1; 48 } 49 static void Solve(double l, double r) { 50 double t1, t2, t3, r1, r2, r3, A, B, C, D, flag; 51 point c1, c2, c3, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; 52 r1 = r2 = r3 = 0; 53 c1 = new point(); 54 for(int tt = 1;tt <= 66;tt ++) { 55 r1 = (l + r) / 2; 56 flag = 0; 57 tmp1 = unitp(dec(p[1], p[0])); 58 tmp2 = unitp(dec(p[2], p[0])); 59 tmp3 = inc(tmp1, tmp2); 60 t3 = Math.acos(dot(tmp1, tmp2) / length(tmp1) / length(tmp2)); 61 t1 = r1 / (Math.sin(t3 / 2)); 62 t2 = length(tmp3); 63 c1 = inc(p[0], new point(t1 / t2 * tmp3.x, t1 / t2 * tmp3.y)); 64 65 tmp1 = unitp(dec(p[0], p[1])); 66 tmp2 = unitp(dec(p[2], p[1])); 67 tmp3 = inc(tmp1, tmp2); 68 tmp4 = dec(c1, p[1]); 69 t3 = Math.acos(dot(tmp1, tmp2) / length(tmp1) / length(tmp2)); 70 t1 = Math.sin(t3 / 2); 71 t2 = length(tmp3); 72 A = sqr(t1 * t2) - sqr(t2); 73 B = (t1 * t2 * r1 + dot(tmp3, tmp4)) * 2; 74 C = sqr(r1) - dot(tmp4, tmp4); 75 D = calc(A, B, C); 76 if(D == -1) flag = 1; 77 c2 = inc(p[1], new point(D * tmp3.x, D * tmp3.y)); 78 r2 = t1 * length(new point(D * tmp3.x, D * tmp3.y)); 79 80 tmp1 = unitp(dec(p[0], p[2])); 81 tmp2 = unitp(dec(p[1], p[2])); 82 tmp3 = inc(tmp1, tmp2); 83 tmp4 = dec(c1, p[2]); 84 t3 = Math.acos(dot(tmp1, tmp2) / length(tmp1) / length(tmp2)); 85 t1 = Math.sin(t3 / 2); 86 t2 = length(tmp3); 87 A = sqr(t1 * t2) - sqr(t2); 88 B = (t1 * t2 * r1 + dot(tmp3, tmp4)) * 2; 89 C = sqr(r1) - dot(tmp4, tmp4); 90 D = calc(A, B, C); 91 if(D == -1) flag = 1; 92 c3 = inc(p[2], new point(D * tmp3.x, D * tmp3.y)); 93 r3 = t1 * length(new point(D * tmp3.x, D * tmp3.y)); 94 if(flag == 1 || sqr(c2.x - c3.x) + sqr(c2.y - c3.y) > sqr(r2 + r3)) r = r1 - eps; 95 else l = r1 + eps; 96 } 97 System.out.printf("%.6f %.6f %.6f\n", r1, r2, r3); 98 } 99 public static void main(String []args) { 100 Scanner input = new Scanner(System.in); 101 for(int i = 0;i < 3;i ++) p[i] = new point(); 102 while(true) { 103 for(int i = 0;i < 3;i ++) { 104 p[i].x = input.nextDouble(); 105 p[i].y = input.nextDouble(); 106 } 107 if(length(p[0]) == 0 && length(p[1]) == 0 && length(p[2]) == 0) break; 108 Solve(0, Math.abs(cross(dec(p[1], p[0]), dec(p[2], p[0]))) / (length(dec(p[1], p[0])) + length(dec(p[2], p[0])) + length(dec(p[1], p[2])))); 109 } 110 } 111 }
维基上有公式,戳这里
l里面是关于这个问题的历史...仍然没有给出推导或者证明...
所以代码去看别人的题解就好了,反正也记不住公式hhh
F.一个很裸的矩形周长并,现场只带了矩形面积并的板子
魔改了好久才改对成周长并的板子...所以重写了一发
重点是数据范围居然支持暴力啊淦!暴力艹正解啦,夭寿啦!
(理解的一个关键在与线段树的叶子节点也都是一个线段!)
1 #include <cstdio> 2 #include <algorithm> 3 4 #define rep(i, j, k) for(int i = j;i <= k;i ++) 5 6 using namespace std; 7 8 const int maxn = 20010; 9 10 int n, k1, k2, tot1, tot2; 11 12 int ans, a1[maxn], a2[maxn], sum[maxn], cnt[maxn]; 13 14 struct node { 15 int x, y, c, d; 16 bool operator < (const node &a) const { 17 return c < a.c; 18 } 19 }line1[maxn], line2[maxn]; 20 21 void modify1(int o, int l, int r, int s, int t, int k, int p) { 22 if(s <= l && r <= t) { 23 cnt[o] += k; 24 if(cnt[o]) ans += p * (a1[r + 1] - a1[l] - sum[o]), sum[o] = a1[r + 1] - a1[l]; 25 else if(l == r) ans += p * (a1[r + 1] - a1[l]), sum[o] = 0; 26 else ans += p * (sum[o] - (sum[o << 1] + sum[o << 1 | 1])), sum[o] = sum[o << 1] + sum[o << 1 | 1]; 27 } 28 else { 29 int mid = (l + r) >> 1; 30 if(cnt[o]) p = 0; 31 if(s <= mid) modify1(o << 1, l, mid, s, t, k, p); 32 if(t > mid) modify1(o << 1 | 1, mid + 1, r, s, t, k, p); 33 if(!cnt[o]) sum[o] = sum[o << 1] + sum[o << 1 | 1]; 34 } 35 } 36 37 void modify2(int o, int l, int r, int s, int t, int k, int p) { 38 if(s <= l && r <= t) { 39 cnt[o] += k; 40 if(cnt[o]) ans += p * (a2[r + 1] - a2[l] - sum[o]), sum[o] = a2[r + 1] - a2[l]; 41 else if(l == r) ans += p * (a2[r + 1] - a2[l]), sum[o] = 0; 42 else ans += p * (sum[o] - (sum[o << 1] + sum[o << 1 | 1])), sum[o] = sum[o << 1] + sum[o << 1 | 1]; 43 } 44 else { 45 int mid = (l + r) >> 1; 46 if(cnt[o]) p = 0; 47 if(s <= mid) modify2(o << 1, l, mid, s, t, k, p); 48 if(t > mid) modify2(o << 1 | 1, mid + 1, r, s, t, k, p); 49 if(!cnt[o]) sum[o] = sum[o << 1] + sum[o << 1 | 1]; 50 } 51 } 52 53 int main() { 54 k1 = k2 = 1; 55 int l, r, x[2], y[2]; 56 scanf("%d", &n); 57 rep(i, 1, n) { 58 rep(j, 0, 1) scanf("%d %d", &x[j], &y[j]); 59 line1[++ tot1] = (node){x[0], x[1], y[0], 1}, a1[tot1] = x[0]; 60 line1[++ tot1] = (node){x[0], x[1], y[1],-1}, a1[tot1] = x[1]; 61 line2[++ tot2] = (node){y[0], y[1], x[0], 1}, a2[tot2] = y[0]; 62 line2[++ tot2] = (node){y[0], y[1], x[1],-1}, a2[tot2] = y[1]; 63 } 64 sort(line1 + 1, line1 + tot1 + 1), sort(a1 + 1, a1 + tot1 + 1); 65 sort(line2 + 1, line2 + tot2 + 1), sort(a2 + 1, a2 + tot2 + 1); 66 rep(i, 2, tot1) { 67 if(a1[i] != a1[k1]) 68 a1[++ k1] = a1[i]; 69 if(a2[i] != a2[k2]) 70 a2[++ k2] = a2[i]; 71 } 72 rep(i, 1, tot1) { 73 l = lower_bound(a1 + 1, a1 + k1 + 1, line1[i].x) - a1; 74 r = lower_bound(a1 + 1, a1 + k1 + 1, line1[i].y) - a1 - 1; 75 modify1(1, 1, k1 - 1, l, r, line1[i].d, 1); 76 } 77 rep(i, 1, tot2) { 78 l = lower_bound(a2 + 1, a2 + k2 + 1, line2[i].x) - a2; 79 r = lower_bound(a2 + 1, a2 + k2 + 1, line2[i].y) - a2 - 1; 80 modify2(1, 1, k2 - 1, l, r, line2[i].d, 1); 81 } 82 printf("%d", ans); 83 return 0; 84 }
G.有多种图形,一个比较蠢的思路就是给每个图形造一个类...
但是思考一下,判断不同的图形相交,其实还是在判断边相交
所以都转换成判断线段相交就好了...
(附:如果使用scanf的格式化读入的话,一定要和读入的格式完全相同
因为用格式化读入的话,就不会忽略空格了...
1 #include <cstdio> 2 #include <vector> 3 #include <iostream> 4 #include <algorithm> 5 6 using namespace std; 7 8 #define pr pair<double, double> 9 #define f(p) p.first 10 #define s(p) p.second 11 #define mp make_pair 12 #define pb push_back 13 14 struct node { 15 string m; 16 vector<pr> a; 17 bool operator < (const node &a) const { 18 return m < a.m; 19 } 20 }; 21 22 int n; 23 24 char s[10]; 25 26 node tmp; 27 28 pr temp[20]; 29 30 vector<node> h; 31 32 vector<string> ans[30]; 33 34 double cross(pr p1, pr p2) { 35 return f(p1) * s(p2) - f(p2) * s(p1); 36 } 37 38 bool line_cross(pr p1, pr p2, pr p3, pr p4) { 39 double t1 = cross(mp(f(p2) - f(p1), s(p2) - s(p1)), mp(f(p3) - f(p1), s(p3) - s(p1))); 40 double t2 = cross(mp(f(p2) - f(p1), s(p2) - s(p1)), mp(f(p4) - f(p1), s(p4) - s(p1))); 41 double t3 = cross(mp(f(p4) - f(p3), s(p4) - s(p3)), mp(f(p1) - f(p3), s(p1) - s(p3))); 42 double t4 = cross(mp(f(p4) - f(p3), s(p4) - s(p3)), mp(f(p2) - f(p3), s(p2) - s(p3))); 43 if(!(1ll * t1 * t2 < 0 || ((t1 == 0 || t2 == 0) && (t1 + t2 != 0)))) return 0; 44 if(!(1ll * t3 * t4 < 0 || ((t3 == 0 || t4 == 0) && (t3 + t4 != 0)))) return 0; 45 return 1; 46 } 47 48 int main() { 49 while(scanf("%s", s)) { 50 if(s[0] == '.') return 0; 51 if(s[0] == '-') { 52 sort(h.begin(), h.end()); 53 for(int i = 0;i < h.size();i ++) { 54 ans[i].clear(); 55 for(int j = 0;j < h.size();j ++) { 56 if(i == j) continue; 57 int x = 0; 58 for(int p = 1;p < h[i].a.size();p ++) { 59 for(int q = 1;q < h[j].a.size();q ++) { 60 if(line_cross(h[i].a[p - 1], h[i].a[p], h[j].a[q - 1], h[j].a[q])) x = 1; 61 if(x) break; 62 } 63 if(x) break; 64 } 65 if(x) ans[i].pb(h[j].m); 66 } 67 switch(ans[i].size()) { 68 case 0:cout << h[i].m << " has no intersections" <<endl; 69 break; 70 case 1:cout << h[i].m << " intersects with " << ans[i][0] << endl; 71 break; 72 case 2:cout << h[i].m << " intersects with " << ans[i][0] << " and " << ans[i][1] <<endl; 73 break; 74 default:{ 75 cout << h[i].m << " intersects with "; 76 for(int j = 0;j + 1 < ans[i].size();j ++) 77 cout << ans[i][j] << ", "; 78 cout << "and " << ans[i][ans[i].size() - 1] << endl; 79 break; 80 } 81 } 82 } 83 h.clear(); 84 puts(""); 85 } 86 else { 87 tmp.a.clear(); 88 tmp.m = s; 89 scanf("%s", s); 90 switch(s[0]) { 91 case 'l':{ 92 scanf(" (%lf,%lf)", &f(temp[0]), &s(temp[0])); 93 scanf(" (%lf,%lf)", &f(temp[1]), &s(temp[1])); 94 tmp.a.pb(temp[0]); 95 tmp.a.pb(temp[1]); 96 break; 97 } 98 case 't':{ 99 scanf(" (%lf,%lf)", &f(temp[0]), &s(temp[0])); 100 scanf(" (%lf,%lf)", &f(temp[1]), &s(temp[1])); 101 scanf(" (%lf,%lf)", &f(temp[2]), &s(temp[2])); 102 tmp.a.pb(temp[0]); 103 tmp.a.pb(temp[1]); 104 tmp.a.pb(temp[2]); 105 break; 106 } 107 case 'p' :{ 108 cin >> n; 109 for(int i = 0;i < n;i ++) { 110 scanf(" (%lf,%lf)", &f(temp[i]), &s(temp[i])); 111 tmp.a.pb(temp[i]); 112 } 113 break; 114 } 115 case 'r':{ 116 scanf(" (%lf,%lf)", &f(temp[0]), &s(temp[0])); 117 scanf(" (%lf,%lf)", &f(temp[1]), &s(temp[1])); 118 scanf(" (%lf,%lf)", &f(temp[2]), &s(temp[2])); 119 tmp.a.pb(temp[0]); 120 tmp.a.pb(temp[1]); 121 tmp.a.pb(temp[2]); 122 temp[3] = mp(f(temp[0]) + f(temp[2]) - f(temp[1]), s(temp[0]) + s(temp[2]) - s(temp[1])); 123 tmp.a.pb(temp[3]); 124 break; 125 } 126 case 's':{ 127 scanf(" (%lf,%lf)", &f(temp[0]), &s(temp[0])); 128 scanf(" (%lf,%lf)", &f(temp[2]), &s(temp[2])); 129 f(temp[4]) = (f(temp[0]) + f(temp[2])) / 2; 130 s(temp[4]) = (s(temp[0]) + s(temp[2])) / 2; 131 tmp.a.pb(temp[0]); 132 tmp.a.pb(mp(f(temp[4]) - s(temp[2]) + s(temp[4]), s(temp[4]) + f(temp[2]) - f(temp[4]))); 133 tmp.a.pb(temp[2]); 134 tmp.a.pb(mp(f(temp[4]) + s(temp[2]) - s(temp[4]), s(temp[4]) - f(temp[2]) + f(temp[4]))); 135 break; 136 } 137 } 138 tmp.a.pb(tmp.a[0]); 139 h.pb(tmp); 140 } 141 } 142 }
H.
占坑