当前位置: 首页 > 编程日记 > 正文

uvalive 3218 Find the Border

题意:一条封闭折线将平面分成了若干个区域,按顺序给出折线各点的坐标,要求输出封闭折线的轮廓。
题解:用类似卷包裹的算法,先确定一个一定会被选中的点(x坐标最小,y坐标最小)作为起点,然后把可能是下一个极点(凸包顶点)的点都存起来,下一个极点有可能是当前点所在线段的前一个点和后一个点或当前点所在线段和其他线段的有交点的线段的起点和终点。
找出最右侧的点(用角度判断)和当前点的连线是否和其他线段有交点,如果有就找最近的交点当做答案的下一个点,如果没有最右侧的点就是下一个点。最后转回起点结束。

  1 #include <cstdio>
  2 #include <cstring>
  3 #include <cmath>
  4 #include <algorithm>
  5 using namespace std;
  6 const double PI = acos(-1);
  7 const double eps = 1e-9;
  8 struct Point
  9 {
 10     double x, y;
 11     Point(double x = 0, double y = 0): x(x), y(y) {}
 12 };
 13 typedef Point Vector;
 14 double dcmp(double x)
 15 {
 16     if (fabs(x) < eps)
 17         return 0;
 18     return x < 0 ? -1 : 1;
 19 }
 20 Vector operator + (const Point& A, const Point& B)
 21 {
 22     return Vector(A.x + B.x, A.y + B.y);
 23 }
 24 Vector operator - (const Point& A, const Point& B)
 25 {
 26     return Vector(A.x - B.x, A.y - B.y);
 27 }
 28 Vector operator * (const Point& A, double a)
 29 {
 30     return Vector(A.x * a, A.y * a);
 31 }
 32 Vector operator / (const Point& A, double a)
 33 {
 34     return Vector(A.x / a, A.y / a);
 35 }
 36 double Cross(const Vector& A, const Vector& B)
 37 {
 38     return A.x * B.y - A.y * B.x;
 39 }
 40 double Dot(const Vector& A, const Vector& B)
 41 {
 42     return A.x * B.x + A.y * B.y;
 43 }
 44 double Length(const Vector& A)
 45 {
 46     return sqrt(Dot(A, A));
 47 }
 48 bool operator < (const Point& A, const Point& B)
 49 {
 50     return A.x < B.x || (A.x == B.x && A.y < B.y);
 51 }
 52 bool operator == (const Point& A, const Point& B)
 53 {
 54     return A.x == B.x && A.y == B.y;
 55 }
 56 Point GetLineIntersection(Point P, Point v, Point Q, Point w)
 57 {
 58     Point u = P - Q;
 59     double t = Cross(w, u) / Cross(v, w);
 60     return P + v * t;
 61 }
 62 bool SegmentProperIntersection(const Point& a1, const Point& a2, const Point& b1, const Point& b2)
 63 {
 64     double c1 = Cross(a2 - a1, b1 - a1);
 65     double c2 = Cross(a2 - a1, b2 - a1);
 66     double c3 = Cross(b2 - b1, a1 - b1);
 67     double c4 = Cross(b2 - b1, a2 - b1);
 68     return dcmp(c1) * dcmp(c2) < 0 && dcmp(c3) * dcmp(c4) < 0;
 69 }
 70 bool OnSegment(const Point& p, const Point& a1, const Point& a2)
 71 {
 72     return dcmp(Cross(a1 - p, a2 - p)) == 0 && dcmp(Dot(a1 - p, a2 - p)) < 0;
 73 }
 74 
 75 const int N = 10005;
 76 const int M = 205;
 77 Point P[M], res[N], temp[M];
 78 double ang[M], s;
 79 int n, cnt;
 80 
 81 void add(Point a, Point b)
 82 {
 83     temp[cnt] = a;
 84     ang[cnt] = atan2(temp[cnt].y - b.y, temp[cnt].x - b.x) - s;
 85     while (dcmp(ang[cnt]) <= 0)
 86         ang[cnt] += 2 * PI;
 87     cnt++;
 88 }
 89 
 90 int main()
 91 {
 92     while (scanf("%d", &n) == 1)
 93     {
 94         int minid = 0;
 95         for (int i = 0; i < n; i++)
 96         {
 97             scanf("%lf%lf", &P[i].x, &P[i].y);
 98             if (P[i] < P[minid])
 99                 minid = i;
100         }
101         res[0] = P[minid];
102         int num = 1;
103         s = -PI;
104         while (1)
105         {
106             cnt = 0;
107             for (int i = 0; i < n; i++)
108             {
109                 if (res[num - 1] == P[i])
110                 {
111                     add(P[(i + 1) % n], res[num - 1]);
112                     add(P[(i + n - 1) % n], res[num - 1]);
113                     break;
114                 }
115             }
116             for (int i = 0; i < n; i++)
117             {
118                 if (OnSegment(res[num - 1], P[i], P[(i + 1) % n]))
119                 {
120                     add(P[(i + 1) % n], res[num - 1]);
121                     add(P[i], res[num - 1]);
122                 }
123             }
124             int id = 0;
125             for (int i = 0; i < cnt; i++)
126                 if (ang[i] < ang[id])
127                     id = i;
128             double minlen = 1e9;
129             Point RP = temp[id], its;
130             for (int i = 0; i < n; i++)
131             {
132                 if (SegmentProperIntersection(temp[id], res[num - 1], P[i], P[(i + 1) % n]))
133                 {
134                     its = GetLineIntersection(temp[id], temp[id] - res[num - 1], P[i], P[i] - P[(i + 1) % n]);
135                     if (Length(its - res[num - 1]) < minlen)
136                     {
137                         minlen = Length(its - res[num - 1]);
138                         RP = its;
139                     }
140                 }
141             }
142             res[num] = RP;
143             s = atan2(res[num - 1].y - res[num].y, res[num - 1].x - res[num].x);
144             num++;
145             if (res[num - 1] == res[0])
146                 break;
147         }
148         printf("%d\n", num - 1);
149         for (int i = 0; i < num - 1; i++)
150             printf("%.4lf %.4lf\n", res[i].x, res[i].y);
151     }
152     return 0;
153 }
View Code

后一种解法是用PSLG的外轮廓。

  1 #include<cstdio>
  2 #include<vector>
  3 #include<cmath>
  4 #include<algorithm>
  5 #include<cstring>
  6 #include<cassert>
  7 using namespace std;
  8 
  9 const double eps = 1e-8;
 10 double dcmp(double x)
 11 {
 12     if(fabs(x) < eps) return 0;
 13     else return x < 0 ? -1 : 1;
 14 }
 15 
 16 struct Point
 17 {
 18     double x, y;
 19     Point(double x=0, double y=0):x(x),y(y) { }
 20 };
 21 
 22 typedef Point Vector;
 23 
 24 Vector operator + (Vector A, Vector B)
 25 {
 26     return Vector(A.x+B.x, A.y+B.y);
 27 }
 28 
 29 Vector operator - (Point A, Point B)
 30 {
 31     return Vector(A.x-B.x, A.y-B.y);
 32 }
 33 
 34 Vector operator * (Vector A, double p)
 35 {
 36     return Vector(A.x*p, A.y*p);
 37 }
 38 
 39 // 理论上这个“小于”运算符是错的,因为可能有三个点a, b, c, a和b很接近(即a<b好b<a都不成立),b和c很接近,但a和c不接近
 40 // 所以使用这种“小于”运算符的前提是能排除上述情况
 41 bool operator < (const Point& a, const Point& b)
 42 {
 43     return dcmp(a.x - b.x) < 0 || (dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) < 0);
 44 }
 45 
 46 bool operator == (const Point& a, const Point &b)
 47 {
 48     return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
 49 }
 50 
 51 double Dot(Vector A, Vector B)
 52 {
 53     return A.x*B.x + A.y*B.y;
 54 }
 55 double Cross(Vector A, Vector B)
 56 {
 57     return A.x*B.y - A.y*B.x;
 58 }
 59 double Length(Vector A)
 60 {
 61     return sqrt(Dot(A, A));
 62 }
 63 
 64 typedef vector<Point> Polygon;
 65 
 66 Point GetLineIntersection(const Point& P, const Vector& v, const Point& Q, const Vector& w)
 67 {
 68     Vector u = P-Q;
 69     double t = Cross(w, u) / Cross(v, w);
 70     return P+v*t;
 71 }
 72 
 73 bool SegmentProperIntersection(const Point& a1, const Point& a2, const Point& b1, const Point& b2)
 74 {
 75     double c1 = Cross(a2-a1,b1-a1), c2 = Cross(a2-a1,b2-a1),
 76            c3 = Cross(b2-b1,a1-b1), c4=Cross(b2-b1,a2-b1);
 77     return dcmp(c1)*dcmp(c2)<0 && dcmp(c3)*dcmp(c4)<0;
 78 }
 79 
 80 bool OnSegment(Point p, Point a1, Point a2)
 81 {
 82     return dcmp(Cross(a1-p, a2-p)) == 0 && dcmp(Dot(a1-p, a2-p)) < 0;
 83 }
 84 
 85 // 多边形的有向面积
 86 double PolygonArea(Polygon poly)
 87 {
 88     double area = 0;
 89     int n = poly.size();
 90     for(int i = 1; i < n-1; i++)
 91         area += Cross(poly[i]-poly[0], poly[(i+1)%n]-poly[0]);
 92     return area/2;
 93 }
 94 
 95 struct Edge
 96 {
 97     int from, to; // 起点,终点,左边的面编号
 98     double ang;
 99 };
100 
101 const int maxn = 10000 + 10; // 最大边数
102 
103 // 平面直线图(PSGL)实现
104 struct PSLG
105 {
106     int n, m, face_cnt;
107     double x[maxn], y[maxn];
108     vector<Edge> edges;
109     vector<int> G[maxn];
110     int vis[maxn*2];  // 每条边是否已经访问过
111     int left[maxn*2]; // 左面的编号
112     int prev[maxn*2]; // 相同起点的上一条边(即顺时针旋转碰到的下一条边)的编号
113 
114     vector<Polygon> faces;
115     double area[maxn]; // 每个polygon的面积
116 
117     void init(int n)
118     {
119         this->n = n;
120         for(int i = 0; i < n; i++) G[i].clear();
121         edges.clear();
122         faces.clear();
123     }
124 
125     // 有向线段from->to的极角
126     double getAngle(int from, int to)
127     {
128         return atan2(y[to]-y[from], x[to]-x[from]);
129     }
130 
131     void AddEdge(int from, int to)
132     {
133         edges.push_back((Edge)
134         {
135             from, to, getAngle(from, to)
136         });
137         edges.push_back((Edge)
138         {
139             to, from, getAngle(to, from)
140         });
141         m = edges.size();
142         G[from].push_back(m-2);
143         G[to].push_back(m-1);
144     }
145 
146     // 找出faces并计算面积
147     void Build()
148     {
149         for(int u = 0; u < n; u++)
150         {
151             // 给从u出发的各条边按极角排序
152             int d = G[u].size();
153             for(int i = 0; i < d; i++)
154                 for(int j = i+1; j < d; j++) // 这里偷个懒,假设从每个点出发的线段不会太多
155                     if(edges[G[u][i]].ang > edges[G[u][j]].ang) swap(G[u][i], G[u][j]);
156             for(int i = 0; i < d; i++)
157                 prev[G[u][(i+1)%d]] = G[u][i];
158         }
159 
160         memset(vis, 0, sizeof(vis));
161         face_cnt = 0;
162         for(int u = 0; u < n; u++)
163             for(int i = 0; i < G[u].size(); i++)
164             {
165                 int e = G[u][i];
166                 if(!vis[e])   // 逆时针找圈
167                 {
168                     face_cnt++;
169                     Polygon poly;
170                     for(;;)
171                     {
172                         vis[e] = 1;
173                         left[e] = face_cnt;
174                         int from = edges[e].from;
175                         poly.push_back(Point(x[from], y[from]));
176                         e = prev[e^1];
177                         if(e == G[u][i]) break;
178                         assert(vis[e] == 0);
179                     }
180                     faces.push_back(poly);
181                 }
182             }
183 
184         for(int i = 0; i < faces.size(); i++)
185         {
186             area[i] = PolygonArea(faces[i]);
187         }
188     }
189 };
190 
191 PSLG g;
192 
193 const int maxp = 100 + 5;
194 int n, c;
195 Point P[maxp];
196 
197 Point V[maxp*(maxp-1)/2+maxp];
198 
199 // 在V数组里找到点p
200 int ID(Point p)
201 {
202     return lower_bound(V, V+c, p) - V;
203 }
204 
205 // 假定poly没有相邻点重合的情况,只需要删除三点共线的情况
206 Polygon simplify(const Polygon& poly)
207 {
208     Polygon ans;
209     int n = poly.size();
210     for(int i = 0; i < n; i++)
211     {
212         Point a = poly[i];
213         Point b = poly[(i+1)%n];
214         Point c = poly[(i+2)%n];
215         if(dcmp(Cross(a-b, c-b)) != 0) ans.push_back(b);
216     }
217     return ans;
218 }
219 
220 void build_graph()
221 {
222     c = n;
223     for(int i = 0; i < n; i++)
224         V[i] = P[i];
225 
226     vector<double> dist[maxp]; // dist[i][j]是第i条线段上的第j个点离起点(P[i])的距离
227     for(int i = 0; i < n; i++)
228         for(int j = i+1; j < n; j++)
229             if(SegmentProperIntersection(P[i], P[(i+1)%n], P[j], P[(j+1)%n]))
230             {
231                 Point p = GetLineIntersection(P[i], P[(i+1)%n]-P[i], P[j], P[(j+1)%n]-P[j]);
232                 V[c++] = p;
233                 dist[i].push_back(Length(p - P[i]));
234                 dist[j].push_back(Length(p - P[j]));
235             }
236 
237     // 为了保证“很接近的点”被看作同一个,这里使用了sort+unique的方法
238     // 必须使用前面提到的“理论上是错误”的小于运算符,否则不能保证“很接近的点”在排序后连续排列
239     // 另一个常见的处理方式是把坐标扩大很多倍(比如100000倍),然后四舍五入变成整点(计算完毕后再还原),用少许的精度损失换来鲁棒性和速度。
240     sort(V, V+c);
241     c = unique(V, V+c) - V;
242 
243     g.init(c); // c是平面图的点数
244     for(int i = 0; i < c; i++)
245     {
246         g.x[i] = V[i].x;
247         g.y[i] = V[i].y;
248     }
249     for(int i = 0; i < n; i++)
250     {
251         Vector v = P[(i+1)%n] - P[i];
252         double len = Length(v);
253         dist[i].push_back(0);
254         dist[i].push_back(len);
255         sort(dist[i].begin(), dist[i].end());
256         int sz = dist[i].size();
257         for(int j = 1; j < sz; j++)
258         {
259             Point a = P[i] + v * (dist[i][j-1] / len);
260             Point b = P[i] + v * (dist[i][j] / len);
261             if(a == b) continue;
262             g.AddEdge(ID(a), ID(b));
263         }
264     }
265 
266     g.Build();
267 
268     Polygon poly;
269     for(int i = 0; i < g.faces.size(); i++)
270         if(g.area[i] < 0)   // 对于连通图,惟一一个面积小于零的面是无限面
271         {
272             poly = g.faces[i];
273             reverse(poly.begin(), poly.end()); // 对于内部区域来说,无限面多边形的各个顶点是顺时针的
274             poly = simplify(poly); // 无限面多边形上可能会有相邻共线点
275             break;
276         }
277 
278     int m = poly.size();
279     printf("%d\n", m);
280 
281     // 挑选坐标最小的点作为输出的起点
282     int start = 0;
283     for(int i = 0; i < m; i++)
284         if(poly[i] < poly[start]) start = i;
285     for(int i = start; i < m; i++)
286         printf("%.4lf %.4lf\n", poly[i].x, poly[i].y);
287     for(int i = 0; i < start; i++)
288         printf("%.4lf %.4lf\n", poly[i].x, poly[i].y);
289 }
290 
291 int main()
292 {
293     while(scanf("%d", &n) == 1 && n)
294     {
295         for(int i = 0; i < n; i++)
296         {
297             int x, y;
298             scanf("%d%d", &x, &y);
299             P[i] = Point(x, y);
300         }
301         build_graph();
302     }
303     return 0;
304 }
View Code

转载于:https://www.cnblogs.com/ITUPC/p/4893463.html

相关文章:

[Mac] mac linux 多线程下载利器 axel

​> 之前做过一些文件下载的统计&#xff0c;发现谷歌浏览器chrome和火狐firefox, 一般都是单线程的下载文件&#xff0c;360浏览器却是多线程的下载。如今切换到了mac上&#xff0c;发现没有360哪个浏览器&#xff0c;就像找个在linux或者mac下能够多线程下载的工具。 linu…

antd 表单提交,文件和表单内容一起提交,表单校验

用很简单的源码实现包含下列 antd 表单相关知识: 1.表单必填校验,规则校验 2.Upload 上传图片,获取上传图片的状态,如上传成功,上传失败,上传进度条,删除上传的文件 3.获取 Input 组件用户输入的值,设置默认值 4.提交表单不刷新页面 5.把上传的图片显示在页面 页面…

代码注释//_您应该停止编写//的五个代码注释,并且//应该开始的一个注释

代码注释//提供来自您最喜欢和最受欢迎的开源项目的示例-React&#xff0c;Angular&#xff0c;PHP&#xff0c;Pandas等&#xff01; (With examples from your favorite and most popular open source projects — React, Angular, PHP, Pandas and more!) 代码质量与注释之间…

eclipse安装maven

maven 下载地址&#xff1a;http://maven.apache.org/download.cgi 1.maven环境配置 将下载的maven解压到某一盘下&#xff0c;进入E:\maven\apache-maven-3.3.9\conf目录&#xff0c;修改setting.xml文件 找到<localRepository>节点&#xff0c;配置本地仓库的地址&…

微信小程序 循迹功能制作

规划地图的路径&#xff0c;实时获取用户当前的定位&#xff0c;进行路线循迹导航功能的开发&#xff1a; 效果图&#xff1a; 实现代码&#xff1a; <map id"map" enable-satellite longitude"{{longitude1}}" latitude"{{latitude1}}" sca…

DOM解析和SAX解析的区别

DOM解析和SAX解析的区别 博客分类&#xff1a; XMLDOM SAX DOM解析和SAX解析的区别 No区 别DOM解析SAX解析1操作将所有文件读取到内存中形成DOM树&#xff0c;如果文件量过大&#xff0c;则无法使用顺序读入所需要的文件内容&#xff0c;不会一次性全部读取&#xff0c;不受文件…

java编写代码用什么_如何学习用Java编写代码:为什么要学习以及从哪里开始

java编写代码用什么by John Selawsky约翰塞劳斯基(John Selawsky) 如何学习用Java编写代码&#xff1a;为什么要学习以及从哪里开始 (How to learn to code in Java: why you should and where to start) Define your career goals and choose a language. This is the most i…

迷宫寻宝(搜索)

迷宫寻宝&#xff08;一&#xff09; 时间限制&#xff1a;1000 ms | 内存限制&#xff1a;65535 KB难度&#xff1a;4描述一个叫ACM的寻宝者找到了一个藏宝图&#xff0c;它根据藏宝图找到了一个迷宫&#xff0c;这是一个很特别的迷宫&#xff0c;迷宫里有N个编过号的门&…

理解Python的迭代器(转)

原文地址: http://python.jobbole.com/81916/ 另外一篇文章: http://www.cnblogs.com/kaituorensheng/p/3826911.html 什么是迭代 可以直接作用于for循环的对象统称为可迭代对象(Iterable)。 可以被next()函数调用并不断返回下一个值的对象称为迭代器(Iterator)。 所有的Iterab…

快捷导航动画制作

做了一个仿大众点评的快捷导航动画效果&#xff0c;点击导航内的箭头&#xff0c;导航缩放&#xff0c;点击快捷导航再伸展。 看效果图&#xff1a; 实现代码&#xff1a; <block wx:if"{{!isCustom}}"><view class"home_and_reSource" animati…

instant apps_Android Instant Apps 101:它们是什么以及它们如何工作

instant appsby Tomislav Smrečki通过TomislavSmrečki Android Instant Apps are a cool new way to consume native apps without prior installation. Only parts of the app are downloaded and launched, giving the users a native look and feel in a couple of secon…

数据库分享一: MySQL的Innodb缓存相关优化

无论是对于哪一种数据库来说&#xff0c;缓存技术都是提高数据库性能的关键技术&#xff0c;物理磁盘的访问速度永 远都会与内存的访问速度永远都不是一个数量级的。通过缓存技术无论是在读还是写方面都可以大大提 高数据库整体性能。Innodb_buffer_pool_size 的合理设置Innodb…

用过美德乐吸奶器的宝妈们感觉比国产吸奶器怎么样啊?

药效好不好&#xff0c;看疗效就知道。吸奶器好不好看评价就知道。我们来看看美德乐吸奶器 天猫旗舰店 : http://medela.wang 的宝妈们的评价如可 拔奶神器&#xff0c;绝对好过贝亲&#xff01;最初一次七八十&#xff0c;后来一百多&#xff0c;现在可以翻个倍。结合宝宝吮吸…

小程序地图多个 circles 使用demo

效果图&#xff1a; 代码&#xff1a; var that; const app getApp() const util require("../../utils/util.js") const data require("../../utils/map.js") Page({data: {pageShow: false,scale: 15,obj: {},longitude: 116.34665554470486,latitud…

编写文档_如何通过编写优质文档来使自己的未来快乐

编写文档by Gabriele Cimato加布里埃莱西马托(Gabriele Cimato) 如何通过编写优质文档来使自己的未来快乐 (How to make your future self happy by writing good docs) 或者&#xff0c;在清除旧代码库时如何减少痛苦 (Or how to be less miserable when dusting off an old …

(转载)人人都会OSGI--实例讲解OSGI开发

http://longdick.iteye.com/blog/457310转载于:https://www.cnblogs.com/eecs2016/articles/7422310.html

小程序json字符串转 json对象 { name :你好} 转成 { name :你好}

解决后端接口返回 var obj "{ name :"你好"}" 类似这样的数据&#xff0c;对象或者数组外面包了一层引号&#xff0c; 把这种数据转成 var obj { name :"你好"}&#xff1b; 直接上代码&#xff1a; // pages/test/test.js Page({jsonStrToJ…

每天写的叫工作日志,每周写的总结叫周报,每月写的叫月报

有些时候&#xff0c;老板会突发让您求每天都要写工作周报&#xff0c;什么项目什么任务&#xff0c;完成情况&#xff0c;完成花费的时间等&#xff0c;然后汇总部门周报&#xff1b;也不是写不出&#xff0c;只是不知道有时候重复做一个项目&#xff0c;到底每天有什么好写&a…

为什么分散刷新没有死时间_分散项目为何失败(以及如何处理)

为什么分散刷新没有死时间The most exciting thing about working in the decentralized economy is the fact that no one has any idea as to where it’ll all end up!在去中心decentralized economy工作最令人振奋的事情是&#xff0c;没有人知道最终的结果&#xff01; T…

.NET Core 常用加密和Hash工具NETCore.Encrypt

前言 在日常开发过程中&#xff0c;不可避免的涉及到数据加密解密&#xff08;Hash&#xff09;操作&#xff0c;所以就有想法开发通用工具&#xff0c;NETCore.Encrypt就诞生了。目前NETCore.Encrypt只支持.NET Core ,工具包含了AES,DES,RSA加密解密&#xff0c;MD5&#xff0…

url 通配符解析成参数

需求&#xff1a;url 参数是通配符&#xff0c;需要把通配符解析成参数并且拼接到 url 中 例如&#xff1a;https://xxx.cn/index.html$a1$b2; 解析成 https://xxx.cn/index.html?a1&b2; 时间关系&#xff0c;直接上代码&#xff0c;有时间再补上注释 下面是小程序页…

性能测试分享:系统架构

性能测试分享&#xff1a;系统架构 转载于:https://www.cnblogs.com/poptest/p/4904584.html

graphql是什么_为什么GraphQL是避免技术债务的关键

graphql是什么GraphQL (not to be confused with GraphDB or Open Graph or even an actual graph) is a remarkably creative solution to a relatively common problem: How do you enable front end developers to access backend data in exactly the way they need it?Gr…

JS如何判断json是否为空

1、判断json是否为空 jQuery.isEmptyObject()&#xff1b; 2、遍历json function getHsonLength(json{var jsonLength0;for (var i in json){jsonLength;}return jsonLength;}转载于:https://www.cnblogs.com/donaldworld/p/7423811.html

微软算法100题11 求二叉树中两节点之间的最大距离

第11 题求二叉树中节点的最大距离...如果我们把二叉树看成一个图&#xff0c;父子节点之间的连线看成是双向的&#xff0c;我们姑且定义"距离"为两节点之间边的个数。写一个程序&#xff0c;求一棵二叉树中相距最远的两个节点之间的距离 思路: 一棵树中节点的最大距…

小程序订阅消息 订阅消息开发

微信小程序交流QQ群&#xff1a; 173683895 173683866 526474645 。 群内打广告或者脏话一律飞机票 订阅消息 当用户勾选了订阅面板中的“总是保持以上选择&#xff0c;不再询问”时&#xff0c;模板消息会被添加到用户的小程序设置页&#xff0c;通过 wx.getSetting…

meetup_如何使用标准库和Node.js构建Meetup Slack机器人

meetupby Janeth Ledezma简妮丝莱德兹玛(Janeth Ledezma) 如何使用标准库和Node.js构建Meetup Slack机器人 (How to build a Meetup Slack bot with Standard Library and Node.js) In this guide, you will learn how to set up a Slack application that will display infor…

.NET使用OpenSSL生成的pem密钥文件[1024位]

using System; using System.Text; using System.Security.Cryptography; using System.Web; using System.IO;namespace Thinhunan.Cnblogs.Com.RSAUtility {public class PemConverter{/// <summary>/// 将pem格式公钥转换为RSAParameters/// </summary>/// <…

[2014百度之星资格赛]

第一个问题&#xff1a; Energy Conversion Problem Description魔法师百小度也有遇到难题的时候——如今。百小度正在一个古老的石门面前&#xff0c;石门上有一段古老的魔法文字&#xff0c;读懂这样的魔法文字须要耗费大量的能量和大量的脑力。过了许久。百小度最终读懂魔法…

视频录制,压缩实现源码

实现代码&#xff1a; <!DOCTYPE html> <html><head><meta charset"utf-8"><title></title><meta name"viewport" content"widthdevice-width, initial-scale1.0"><!-- <script src"./js…