【几何】多少正方形?

题目

多少正方形?
在这里插入图片描述


枚举

设每个横纵相邻点得间距为1,则我们可以依次输出下列边长为 a a a的正方形的数量:

边长为1

a = 1 a=1 a=1
在这里插入图片描述


边长为 2 \sqrt{2} 2

a = 1 2 + 1 2 = 2 a=\sqrt{1^2+1^2}=\sqrt{2} a=12+12 =2
在这里插入图片描述


边长为 5 \sqrt{5} 5

a = 1 2 + 2 2 = 5 a=\sqrt{1^2+2^2}=\sqrt{5} a=12+22 =5
在这里插入图片描述


边长为 8 \sqrt{8} 8

a = 2 2 + 2 2 = 8 a=\sqrt{2^2+2^2}=\sqrt{8} a=22+22 =8

在这里插入图片描述


边长为 13 \sqrt{13} 13

a = 2 2 + 3 2 = 13 a=\sqrt{2^2+3^2}=\sqrt{13} a=22+32 =13
在这里插入图片描述

按上述尺寸数得各个大小正方形数量如下:

{ C 1 = 9 a = 1 C 2 = 4 a = 1 2 + 1 2 = 2 C 3 = 2 a = 1 2 + 2 2 = 5 C 4 = 4 a = 2 2 + 2 2 = 2 2 C 5 = 2 a = 2 2 + 3 2 = 13 \begin{cases} C_1=9 &\text{ } a=1 \\ C_2=4 &\text{ } a=\sqrt{1^2+1^2}=\sqrt{2}\\ C_3=2 &\text{ } a=\sqrt{1^2+2^2}=\sqrt{5}\\ C_4=4 &\text{ } a=\sqrt{2^2+2^2}=2\sqrt{2}\\ C_5=2 &\text{ } a=\sqrt{2^2+3^2}=\sqrt{13} \end{cases} C1=9C2=4C3=2C4=4C5=2 a=1 a=12+12 =2  a=12+22 =5  a=22+22 =22  a=22+32 =13

C = C 1 + C 2 + C 3 + C 4 + C 5 = 9 + 4 + 2 + 4 + 2 = 21 \begin{equation} \begin{split} C&=C_1+C_2+C_3+C_4+C_5 \\ &=9+4+2+4+2 \\ &=21 \end{split} \end{equation} C=C1+C2+C3+C4+C5=9+4+2+4+2=21
在这里插入图片描述

扩展-使用代码来数

1、定义点对象

        /// <summary>/// 点对象/// </summary>public class CPoint{/// <summary>/// 点横坐标/// </summary>public double X { get; set; }/// <summary>/// 点纵坐标/// </summary>public double Y { get; set; }/// <summary>/// 点相对位置角度/// </summary>public double Angle { get; set; }/// <summary>/// 点编号/// </summary>public int Index { get; set; }public CPoint(int index,double x,double y,double a = 0){this.X = x;this.Y = y;this.Index = index;this.Angle = a;}/// <summary>/// 判断两个点是否是同一个点/// </summary>/// <param name="obj"></param>/// <returns></returns>public override bool Equals(object obj){if (obj == null) return false;if (obj.GetType() != typeof(CPoint)) return false;var val =(CPoint) obj;if(this.X == val.X && this.Y == val.Y){return true;}return false;}/// <summary>/// 格式化点对象/// </summary>/// <returns></returns>public override string ToString(){return $"{Index}.({X},{Y}){Angle}";}/// <summary>/// 50倍绘制圆点/// </summary>/// <returns></returns>public RectangleF DrawCircle(){float size = 10;return new RectangleF((float)(X *50 - size / 2), (float)(Y *50 - size / 2), size, size);}/// <summary>/// 50倍绘制点/// </summary>/// <returns></returns>public PointF DrawPnt(){return new PointF((float)(X * 50), (float)(Y * 50));}}

2、定义正方形对象

        /// <summary>/// 正方形对象/// </summary>public class CSqure{/// <summary>/// 正方形的点/// </summary>public List<CPoint> Points { get; set; }/// <summary>/// 正方形边长/// </summary>public double C { get; set; }/// <summary>/// 正方形中心点横坐标/// </summary>public double CenterX { get; set; }/// <summary>/// 正方形中心点纵坐标/// </summary>public double CenterY { get; set; }public CSqure(CPoint pnt1, CPoint pnt2, CPoint pnt3, CPoint pnt4){if (Points == null){Points = new List<CPoint>();}Points.Add(pnt1);Points.Add(pnt2);Points.Add(pnt3);Points.Add(pnt4);}public PointF[] DrawSqure(){return new PointF[4] { Points[0].DrawPnt(), Points[1].DrawPnt(), Points[2].DrawPnt(), Points[3].DrawPnt() };}public PointF DrawCenter(SizeF size){var center = CalculateCenter();var pnt = center.DrawPnt();return new PointF(pnt.X - size.Width / 2, pnt.Y - size.Height / 2);}/// <summary>/// 判断是否正方形/// </summary>/// <returns></returns>public bool IsSqure(){List<double> distances = new List<double>();// Calculate all pairwise distancesfor (int i = 0; i < Points.Count; i++){for (int j = i + 1; j < Points.Count; j++){distances.Add(Distance(Points[i], Points[j]));}}// 将所有点得距离进行排序distances.Sort();// 第一个距离必须大于0,前四个距离依次相等是边,后两个距离是对象线。四边相等且对角线相等为正方形if (distances[0] > 0 && Equal(distances[0], distances[1]) && Equal(distances[1], distances[2]) && Equal(distances[2], distances[3]) &&Equal(distances[4], distances[5])){C = distances[0]; //计算每个点得顺序List<CPoint> polygons = new List<CPoint>();var center = CalculateCenter();CenterX = center.X;CenterY = center.Y;for (int i = 0; i < Points.Count; i++){var angle = CalculateAngle(center, Points[i]);if (angle < 0){angle += 360;}else if (angle >= 360){angle -= 360;}polygons.Add(new CPoint(Points[i].Index, Points[i].X, Points[i].Y, angle));}Points = polygons.OrderBy(o => o.Angle).ToList();return true;}return false;}/// <summary>/// 计算正方形中心点/// </summary>/// <returns></returns>public CPoint CalculateCenter(){double centerX = Points.Average(o => o.X);double centerY = Points.Average(o => o.Y);return new CPoint(0, centerX, centerY);}/// <summary>/// 计算旋转角/// </summary>/// <param name="center"></param>/// <param name="point"></param>/// <returns></returns>public double CalculateAngle(CPoint center, CPoint point){double deltaY = point.Y - center.Y;double deltaX = point.X - center.X;double angleInRadians = Math.Atan2(deltaY, deltaX);double angleInDegrees = angleInRadians * (180.0 / Math.PI);return angleInDegrees;}/// <summary>/// 判断两个距离是否相等/// </summary>/// <param name="d1"></param>/// <param name="d2"></param>/// <returns></returns>public bool Equal(double d1, double d2){if (Math.Abs(d2 - d1) < 0.000001){return true;}return false;}/// <summary>/// 计算两点之间的距离/// </summary>/// <param name="pnt1"></param>/// <param name="pnt2"></param>/// <returns></returns>public double Distance(CPoint pnt1, CPoint pnt2){double a = pnt1.X - pnt2.X;double b = pnt1.Y - pnt2.Y;double c = Math.Sqrt(a * a + b * b);return c;}/// <summary>/// 判断两个正方形是否是同一个正方形/// </summary>/// <param name="obj"></param>/// <returns></returns>public override bool Equals(object obj){if (obj == null) return false;if (obj.GetType() != typeof(CSqure)) return false;var val = (CSqure)obj;if (this.ToString() == obj.ToString()){return true;}return false;}/// <summary>/// 格式化正方形对象/// </summary>/// <returns></returns>public override string ToString(){var temps = Points.OrderBy(o => o.Index);return string.Join("-", temps.Select(o => o.Index));}/// <summary>/// 根据点获取所有正方形/// </summary>/// <param name="Points"></param>/// <returns></returns>public static List<CSqure> GetAllSqures(List<CPoint> Points){List<CSqure> Squres = new List<CSqure>();for (int i = 0; i < Points.Count(); i++){for (int j = 0; j < Points.Count(); j++){for (int k = 0; k < Points.Count(); k++){for (int l = 0; l < Points.Count(); l++){CSqure squre = new CSqure(Points[i], Points[j], Points[k], Points[l]);if (squre.IsSqure())//判断是不是正方形{bool isExist = false;foreach (var item in Squres){if (item.ToString() == squre.ToString()) //判断是不是已经存在{isExist = true;break;}}if (!isExist)//没有找到过则添加到列表{Squres.Add(squre);}}}}}}Squres = Squres.OrderBy(o => o.C).ThenBy(o => o.CenterY).ThenBy(o => o.CenterX).ToList();return Squres;}}

3、初始化所有点

			//Points.Add(new CPoint(index++, 1, 1, 0));//Points.Add(new CPoint(index++, 1, 2, 0));Points.Add(new CPoint(index++, 1, 3, 0));Points.Add(new CPoint(index++, 1, 4, 0));//Points.Add(new CPoint(index++, 1, 5, 0));//Points.Add(new CPoint(index++, 1, 6, 0));//Points.Add(new CPoint(index++, 2, 1, 0));//Points.Add(new CPoint(index++, 2, 2, 0));Points.Add(new CPoint(index++, 2, 3, 0));Points.Add(new CPoint(index++, 2, 4, 0));//Points.Add(new CPoint(index++, 2, 5, 0));//Points.Add(new CPoint(index++, 2, 6, 0));Points.Add(new CPoint(index++, 3, 1, 0));Points.Add(new CPoint(index++, 3, 2, 0));Points.Add(new CPoint(index++, 3, 3, 0));Points.Add(new CPoint(index++, 3, 4, 0));Points.Add(new CPoint(index++, 3, 5, 0));Points.Add(new CPoint(index++, 3, 6, 0));Points.Add(new CPoint(index++, 4, 1, 0));Points.Add(new CPoint(index++, 4, 2, 0));Points.Add(new CPoint(index++, 4, 3, 0));Points.Add(new CPoint(index++, 4, 4, 0));Points.Add(new CPoint(index++, 4, 5, 0));Points.Add(new CPoint(index++, 4, 6, 0));//Points.Add(new CPoint(index++, 5, 1, 0));//Points.Add(new CPoint(index++, 5, 2, 0));Points.Add(new CPoint(index++, 5, 3, 0));Points.Add(new CPoint(index++, 5, 4, 0));//Points.Add(new CPoint(index++, 5, 5, 0));//Points.Add(new CPoint(index++, 5, 6, 0));//Points.Add(new CPoint(index++, 6, 1, 0));//Points.Add(new CPoint(index++, 6, 2, 0));Points.Add(new CPoint(index++, 6, 3, 0));Points.Add(new CPoint(index++, 6, 4, 0));//Points.Add(new CPoint(index++, 6, 5, 0));//Points.Add(new CPoint(index++, 6, 6, 0));

4、调用

public List<CSqure> Squres = CSqure.GetAllSqures(Points);

完整代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace WindowsFormsApp1
{public partial class Form1 : Form{/// <summary>/// 点对象/// </summary>public class CPoint{/// <summary>/// 点横坐标/// </summary>public double X { get; set; }/// <summary>/// 点纵坐标/// </summary>public double Y { get; set; }/// <summary>/// 点相对位置角度/// </summary>public double Angle { get; set; }/// <summary>/// 点编号/// </summary>public int Index { get; set; }public CPoint(int index,double x,double y,double a = 0){this.X = x;this.Y = y;this.Index = index;this.Angle = a;}/// <summary>/// 判断两个点是否是同一个点/// </summary>/// <param name="obj"></param>/// <returns></returns>public override bool Equals(object obj){if (obj == null) return false;if (obj.GetType() != typeof(CPoint)) return false;var val =(CPoint) obj;if(this.X == val.X && this.Y == val.Y){return true;}return false;}/// <summary>/// 格式化点对象/// </summary>/// <returns></returns>public override string ToString(){return $"{Index}.({X},{Y}){Angle}";}/// <summary>/// 50倍绘制圆点/// </summary>/// <returns></returns>public RectangleF DrawCircle(){float size = 10;return new RectangleF((float)(X *50 - size / 2), (float)(Y *50 - size / 2), size, size);}/// <summary>/// 50倍绘制点/// </summary>/// <returns></returns>public PointF DrawPnt(){return new PointF((float)(X * 50), (float)(Y * 50));}}/// <summary>/// 正方形对象/// </summary>public class CSqure{/// <summary>/// 正方形的点/// </summary>public List<CPoint> Points { get; set; }/// <summary>/// 正方形边长/// </summary>public double C { get; set; }/// <summary>/// 正方形中心点横坐标/// </summary>public double CenterX { get; set; }/// <summary>/// 正方形中心点纵坐标/// </summary>public double CenterY { get; set; }public CSqure(CPoint pnt1, CPoint pnt2, CPoint pnt3, CPoint pnt4){if (Points == null){Points = new List<CPoint>();}Points.Add(pnt1);Points.Add(pnt2);Points.Add(pnt3);Points.Add(pnt4);}public PointF[] DrawSqure(){return new PointF[4] { Points[0].DrawPnt(), Points[1].DrawPnt(), Points[2].DrawPnt(), Points[3].DrawPnt() };}public PointF DrawCenter(SizeF size){var center = CalculateCenter();var pnt = center.DrawPnt();return new PointF(pnt.X - size.Width / 2, pnt.Y - size.Height / 2);}/// <summary>/// 判断是否正方形/// </summary>/// <returns></returns>public bool IsSqure(){List<double> distances = new List<double>();// Calculate all pairwise distancesfor (int i = 0; i < Points.Count; i++){for (int j = i + 1; j < Points.Count; j++){distances.Add(Distance(Points[i], Points[j]));}}// 将所有点得距离进行排序distances.Sort();// 第一个距离必须大于0,前四个距离依次相等是边,后两个距离是对象线。四边相等且对角线相等为正方形if (distances[0] > 0 && Equal(distances[0], distances[1]) && Equal(distances[1], distances[2]) && Equal(distances[2], distances[3]) &&Equal(distances[4], distances[5])){C = distances[0]; //计算每个点得顺序List<CPoint> polygons = new List<CPoint>();var center = CalculateCenter();CenterX = center.X;CenterY = center.Y;for (int i = 0; i < Points.Count; i++){var angle = CalculateAngle(center, Points[i]);if (angle < 0){angle += 360;}else if (angle >= 360){angle -= 360;}polygons.Add(new CPoint(Points[i].Index, Points[i].X, Points[i].Y, angle));}Points = polygons.OrderBy(o => o.Angle).ToList();return true;}return false;}/// <summary>/// 计算正方形中心点/// </summary>/// <returns></returns>public CPoint CalculateCenter(){double centerX = Points.Average(o => o.X);double centerY = Points.Average(o => o.Y);return new CPoint(0, centerX, centerY);}/// <summary>/// 计算旋转角/// </summary>/// <param name="center"></param>/// <param name="point"></param>/// <returns></returns>public double CalculateAngle(CPoint center, CPoint point){double deltaY = point.Y - center.Y;double deltaX = point.X - center.X;double angleInRadians = Math.Atan2(deltaY, deltaX);double angleInDegrees = angleInRadians * (180.0 / Math.PI);return angleInDegrees;}/// <summary>/// 判断两个距离是否相等/// </summary>/// <param name="d1"></param>/// <param name="d2"></param>/// <returns></returns>public bool Equal(double d1, double d2){if (Math.Abs(d2 - d1) < 0.000001){return true;}return false;}/// <summary>/// 计算两点之间的距离/// </summary>/// <param name="pnt1"></param>/// <param name="pnt2"></param>/// <returns></returns>public double Distance(CPoint pnt1, CPoint pnt2){double a = pnt1.X - pnt2.X;double b = pnt1.Y - pnt2.Y;double c = Math.Sqrt(a * a + b * b);return c;}/// <summary>/// 判断两个正方形是否是同一个正方形/// </summary>/// <param name="obj"></param>/// <returns></returns>public override bool Equals(object obj){if (obj == null) return false;if (obj.GetType() != typeof(CSqure)) return false;var val = (CSqure)obj;if (this.ToString() == obj.ToString()){return true;}return false;}/// <summary>/// 格式化正方形对象/// </summary>/// <returns></returns>public override string ToString(){var temps = Points.OrderBy(o => o.Index);return string.Join("-", temps.Select(o => o.Index));}/// <summary>/// 根据点获取所有正方形/// </summary>/// <param name="Points"></param>/// <returns></returns>public static List<CSqure> GetAllSqures(List<CPoint> Points){List<CSqure> Squres = new List<CSqure>();for (int i = 0; i < Points.Count(); i++){for (int j = 0; j < Points.Count(); j++){for (int k = 0; k < Points.Count(); k++){for (int l = 0; l < Points.Count(); l++){CSqure squre = new CSqure(Points[i], Points[j], Points[k], Points[l]);if (squre.IsSqure())//判断是不是正方形{bool isExist = false;foreach (var item in Squres){if (item.ToString() == squre.ToString()) //判断是不是已经存在{isExist = true;break;}}if (!isExist)//没有找到过则添加到列表{Squres.Add(squre);}}}}}}Squres = Squres.OrderBy(o => o.C).ThenBy(o => o.CenterY).ThenBy(o => o.CenterX).ToList();return Squres;}}public List<CPoint> Points = new List<CPoint>();public List<CSqure> Squres = new List<CSqure>();Timer timer = new Timer();public Form1(){InitializeComponent();this.DoubleBuffered = true;timer.Tick += Timer_Tick;timer.Interval = 600;timer.Start();int index = 1;//Points.Add(new CPoint(index++, 1, 1, 0));//Points.Add(new CPoint(index++, 1, 2, 0));Points.Add(new CPoint(index++, 1, 3, 0));Points.Add(new CPoint(index++, 1, 4, 0));//Points.Add(new CPoint(index++, 1, 5, 0));//Points.Add(new CPoint(index++, 1, 6, 0));//Points.Add(new CPoint(index++, 2, 1, 0));//Points.Add(new CPoint(index++, 2, 2, 0));Points.Add(new CPoint(index++, 2, 3, 0));Points.Add(new CPoint(index++, 2, 4, 0));//Points.Add(new CPoint(index++, 2, 5, 0));//Points.Add(new CPoint(index++, 2, 6, 0));Points.Add(new CPoint(index++, 3, 1, 0));Points.Add(new CPoint(index++, 3, 2, 0));Points.Add(new CPoint(index++, 3, 3, 0));Points.Add(new CPoint(index++, 3, 4, 0));Points.Add(new CPoint(index++, 3, 5, 0));Points.Add(new CPoint(index++, 3, 6, 0));Points.Add(new CPoint(index++, 4, 1, 0));Points.Add(new CPoint(index++, 4, 2, 0));Points.Add(new CPoint(index++, 4, 3, 0));Points.Add(new CPoint(index++, 4, 4, 0));Points.Add(new CPoint(index++, 4, 5, 0));Points.Add(new CPoint(index++, 4, 6, 0));//Points.Add(new CPoint(index++, 5, 1, 0));//Points.Add(new CPoint(index++, 5, 2, 0));Points.Add(new CPoint(index++, 5, 3, 0));Points.Add(new CPoint(index++, 5, 4, 0));//Points.Add(new CPoint(index++, 5, 5, 0));//Points.Add(new CPoint(index++, 5, 6, 0));//Points.Add(new CPoint(index++, 6, 1, 0));//Points.Add(new CPoint(index++, 6, 2, 0));Points.Add(new CPoint(index++, 6, 3, 0));Points.Add(new CPoint(index++, 6, 4, 0));//Points.Add(new CPoint(index++, 6, 5, 0));//Points.Add(new CPoint(index++, 6, 6, 0));Squres = CSqure.GetAllSqures(Points);}private int drawIndex = 0;private void Timer_Tick(object sender, EventArgs e){drawIndex++;if(drawIndex>Squres.Count()){drawIndex = 1;}Invalidate();}protected override void OnPaint(PaintEventArgs e){e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;foreach (var item in Points){e.Graphics.FillEllipse(SystemBrushes.GrayText, item.DrawCircle()) ;}return;int indexr = 0;int indexg = 0;int indexb = 0;int start = 127;int r = start;int g = start;int b = start;int step = 40;int index=0;foreach (var item in Squres){index++;indexr += step;if(index != drawIndex){continue;}if(indexr>255- start){indexg += step;if (indexg > 255 - start){indexb += step;if (indexb > 255 - start){indexb = 0;indexg = 0;indexb = 0;}indexg = 0;}indexr = 0;}var color = Color.FromArgb(255, r + indexr, g + indexg, b + indexb);var color2 = Color.FromArgb(255,255- r - indexr, 255 - g - indexg, 255 - b - indexb);using (Pen p = new Pen(color))using (Brush b2 = new SolidBrush(color))using (Brush b3 = new SolidBrush(color2)){e.Graphics.FillPolygon(b2, item.DrawSqure());e.Graphics.DrawPolygon(p, item.DrawSqure());var size = e.Graphics.MeasureString($"{index}",this.Font);e.Graphics.DrawString($"{index}",this.Font, b3, item.DrawCenter(size));e.Graphics.DrawString($"{index}.边长:{item.C.ToString("0.00")}", this.Font, b3, new PointF(50,53));}}base.OnPaint(e);}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/34270.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

AMHS工程师的作用

1、AMHS Automatic Material Handling System&#xff0c;自动物料搬运系统在半导体厂中扮演着至关重要的角色。它通过自动化的方式&#xff0c;提高了晶圆厂的空间利用率、减少了机台的闲置时间、提升了生产效率以及产品良率。随着半导体制造工艺的不断进步&#xff0c;特别是…

线程池概念、线程池的不同创建方式、线程池的拒绝策略

文章目录 &#x1f490;线程池概念以及什么是工厂模式&#x1f490;标准库中的线程池&#x1f490;什么是工厂模式&#xff1f;&#x1f490;ThreadPoolExecutor&#x1f490;模拟实现线程池 &#x1f490;线程池概念以及什么是工厂模式 线程的诞生是因为&#xff0c;频繁的创…

3D Web轻量化引擎HOOPS Commuicator是如何创建AEC查看器的?

在当今数字化时代&#xff0c;建筑、工程和施工&#xff08;AEC&#xff09;行业正经历着一场技术革命。HOOPS Communicator&#xff0c;一款基于HOOPS Web平台的3D Web轻量化引擎&#xff0c;正是这场革命的先锋之一。本文将探讨HOOPS Communicator是如何创建AEC查看器的&…

【CentOS 7】深入指南:使用LVM和扩展文件系统增加root分区存储容量

【CentOS 7】深入指南&#xff1a;使用LVM和扩展文件系统增加root分区存储容量 大家好 我是寸铁&#x1f44a; 【CentOS 7】深入指南&#xff1a;使用LVM和扩展文件系统增加root分区存储容量 ✨ 喜欢的小伙伴可以点点关注 &#x1f49d; 前言 在运行CentOS 7服务器或虚拟机时&a…

用户 token 持久化

用户 token 持久化 业务背景&#xff1a;Token的有效期会持续一段时间&#xff0c;在这段时间内没有必要重复请求token&#xff0c;但是Vuex本身是基于内存的管理方式&#xff0c;刷新浏览器Token会丢失&#xff0c;为了避免丢失需要配置持久化进行缓存 基础思路&#xff1a;…

windows powershell 自动补全/自动suggestion

安装PSReadLine 超级管理员下 Install-Module -Name PSReadLine -RequiredVersion 2.3.5具体最新版本&#xff1a;https://www.powershellgallery.com/packages/PSReadLine/ 编辑powersheel配置文件 在~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 如果没有则…

【扫雷游戏】C语言详解

Hi~&#xff01;这里是奋斗的小羊&#xff0c;很荣幸您能阅读我的文章&#xff0c;诚请评论指点&#xff0c;欢迎欢迎 ~~ &#x1f4a5;&#x1f4a5;个人主页&#xff1a;奋斗的小羊 &#x1f4a5;&#x1f4a5;所属专栏&#xff1a;C语言 &#x1f680;本系列文章为个人学习…

lvs集群 Keepalived

Keepalived高可用集群 Keepalived概述 功能 LVS规则管理LVS集群真实服务器状态监测管理VIP Keepalived实现web高可用 安装keepalived软件 在webservers上配置 启动服务 webservers systemctl start keepalived.service ip a s | grep 192.168 #web1主机绑定vip 测试…

o(n)求逆元

线性时间计算逆元 for (int i 2; i < n; i) {inv[i] MOD - (MOD / i * inv[MOD % i] % MOD) % MOD;}线性时间计算阶乘逆元 //先计算出n!的逆元for (int i n - 1; i > 0; i--) {inv[i] inv[i 1] * (i 1) % MOD;}1-n的LCM 对于1-n中所有数的lcm,其应该等于1-n中每个…

Windows资源管理器down了,怎么解

ctrlshiftesc 打开任务管理器 文件 运行新任务 输入 Explorer.exe 资源管理器重启 问题解决 桌面也回来了

5.浏览器存储

1.浏览器本地存储方式 &#xff08;1&#xff09;Cookie 特性: 名称创建后不可修改。遵循同源策略&#xff0c;不能跨域名共享。每个域名下Cookie数量和大小受限&#xff08;约20个&#xff0c;每个4KB&#xff09;。安全性问题&#xff1a;易被拦截&#xff0c;用于会话劫持。…

MoonBit 周报 Vol.46:支持32位无符号整数!

MoonBit 更新 支持了 32 位无符号整数 let num 100U // 32位无符号整数的字面量需要后缀U在 wasm 后端导出返回值类型为 Unit 的函数时&#xff0c;之前导出函数的类型中会有 (result i32)&#xff0c;现在 MoonBit 编译器会自动生成一个没有返回值 wrapper 函数&#xff0c…

爬虫day3

爬虫如何提高效率&#xff1f; 我们可以选择多线程&#xff0c;多进程&#xff0c;协程等操作完成异步爬取。 异步&#xff1a;把一个变成多个 线程&#xff1a;执行单位 进程&#xff1a;资源单位&#xff0c;每一个进程至少有一个线程 if __name__ __main__: print(&qu…

都说HCIE“烂大街”了,说难考都是假的?

在网络技术领域&#xff0c;华为认证互联网专家&#xff08;HCIE&#xff09;长期以来被视为一项高端认证&#xff0c;代表着专业技能和知识水平。 然而&#xff0c;近几年来&#xff0c;考证的重视度直线上升&#xff0c;考HCIE的人越来越多了&#xff0c;考过的人好像也越来越…

C++ | Leetcode C++题解之第162题寻找峰值

题目&#xff1a; 题解&#xff1a; class Solution { public:int findPeakElement(vector<int>& nums) {int n nums.size();// 辅助函数&#xff0c;输入下标 i&#xff0c;返回一个二元组 (0/1, nums[i])// 方便处理 nums[-1] 以及 nums[n] 的边界情况auto get …

在dolphinDB上直接保存一个dataframe为分布式数据表

步骤1&#xff1a;获取链接 import dolphindb as ddb from loguru import loggerdef get_dolphin_session():"""获取dolphinDB的session"""dolphin_config {"host": "127.0.0.1","port": 13900,"username&…

android adb常用命令集

1、系统调试 #adb shell&#xff1a;进入设备的 shell 命令行界面&#xff0c;可以在此执行各种 Linux 命令和特定的 Android 命令。 #adb shell dumpsys&#xff1a;提供关于系统服务和其状态的详细信息。 #adb logcat&#xff1a;实时查看设备的日志信息。可以使用过滤条件来…

arco:a-cascader级联选择器使用及回显

arco 的 a-cascader 级联选择器的回显必须是最后一级 例如&#xff1a;湖北->武汉->光谷 此时传入 wuhan 是不会回显的&#xff0c;必须传入武汉的最后一级 guanggu 才可以。 <a-form-item field"address" label"所在区域"><a-cascader v-…

图片自由变大变小,你要的,就是你想的。

由于经常要写文档和宣传彩页&#xff0c;里面都有涉及图片&#xff0c;强制调整了图片大小&#xff0c;导致图片变得模糊。所以需要提供一个工具&#xff0c;这就变得很重要了。我这里提供java代码&#xff0c;可以进行图片大小调整&#xff0c;至于调多少&#xff0c;你说了算…

震惊!这样制作宣传册,效果竟然如此惊人!

在当今社会&#xff0c;宣传册作为一种重要的宣传手段&#xff0c;其制作质量直接影响到宣传效果。而令人震惊的是&#xff0c;现在有些制作宣传册的方法&#xff0c;其效果竟然如此惊人&#xff01;今天&#xff0c;教大家如何制作宣传册吧&#xff01; 首先&#xff0c;我们要…