A - Smooth Sequences

本文详细解析了如何判断一组数是否构成光滑数列或半光滑数列,通过遍历数列并判断相邻数差值,识别断点并验证其可调整性,最终确定数列属性。

在这里插入图片描述

题目大意:在n个数中所有相邻的两个数差的绝对值如果不大于d,成这n个数为光滑的,否则如果能更换n个数中一个数使其变成光滑的成为半光滑的。现在给你n个数,如果这n个数为光滑的或半光滑的输出Y,否则输出N。

其中光滑的容易判断,再判断出半光滑的,其余都是不光滑的

不光滑的有两种情况:
  1. 一共有两段光滑的数组组成,在两段的交界处存在断点(就是不光滑的地方)。如n=6,d=5 ; 数组为3 7 10 4 5 6。在10 和 4之间就是一个断点。
  2. 有三段光滑的数组,但是中间的只有一个数。如n=7,d = 5;数组为3 7 9 30 1 2 3。在30这个点处出现断点。
断点是否能修改的判断

找到断点后我们还需要判断该断点是否能修改,1情况中有两种修改可能,修改10位置或者修改4位置。在2情况中只能自改30位置,该位置能否修改只需要判断该位置前后的差的绝对值是否不大于2d。

所以我们只需要遍历一遍数组,寻找断点,当断点小于等于1,且点断能修改输出Y,否则输出N

#include <iostream>

using namespace std;

int main()
{
	int n, d;
	int a[1010];
	while (cin >> n && n)
	{
		cin >> d;
		for (int i = 0; i < n; i++)//输入数据
		{
			cin >> a[i];
		}
		int cnt = 0;//计数修改次数
		int flag = 1;//标记是否光滑
		for (int i = 0; i < n - 1; i++)
		{
			if (cnt > 1)//如果修改过两次
			{
				flag = 0;
				break;
			}
			if (abs(a[i] - a[i + 1]) > d)//出现断点
			{
				if (abs(a[i + 1] - a[i + 2]) > d)
				//这就是上面断点的第二种情况
				{
					cnt++;//标记已经修改过一次
					if (abs(a[i] - a[i + 2]) > 2 * d)
					//这种情况只有30的位置能修改,所以只需要判断一次
					{
						flag = 0;
						break;
					}
					i++;//这里需要跳过一次,9后面是30,这里有断点,30能修改,修改有30位置就是光滑的,不需要在判断,而且如果在判断30位置就需要对30重新赋值
				}
				else
				{
					if (abs(a[i] - a[i + 2]) > 2 * d)//能否修改a[i+1]
					{
						if (i - 1 < 0)//这里最好判断a[i]前面是否还有数
						{
							flag = 0;
							break;
						}
						else if (abs(a[i - 1] - a[i + 1]) > 2 * d)//能否修改a[i]
						{
							flag = 0;
							break;
						}
					}

				}
			}
		}
		if (flag)
		{
			cout << "Y\n";
		}
		else
		{
			cout << "N\n";
		}
	}

}
Loading pipeline components...: 100%|██████████████████████████████████████████████████████████████████████████████████| 6/6 [00:09<00:00, 1.56s/it] You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 . Token indices sequence length is longer than the specified maximum sequence length for this model (1513 > 77). Running this sequence through the model will result in indexing errors The following part of your input was truncated because CLIP can only handle sequences up to 77 tokens: [". a sunlit sky gives a daytime feel but could be bright or maybe at night for a different vibe . adding clouds and birds in flight can enhance the futuristic feel without being too distracting . now , the city itself . neon lights are essential — like the ones on buildings , streets , and vehicles . they create that glowing effect which is common in sci - fi settings . the streetlamps should have a modern twist , maybe with neon colors changing over time to show a dynamic look . flying cars need to stand out . maybe have a variety like convertibles , sports cars , and trucks for realism . the colors could shift based on the type — like metallic blue for a sleek car and neon yellow for something flashy . adding white led lights around the wheels would make them pop . the interiors of these cars should be high - tech . glass windows with holographic digits display info while privacy screens keep passengers safe . seats made from something futuristic , maybe carbon fiber or something that looks high - end . the controls on the dashboard could have touch - sensitive panels for a smooth experience . the city 's architecture is another point . tall skyscrapers with transparent facades letting neon light through gives an otherworldly effect . skyscrapers as flying pads where people can take off into space adds a cool element , and a central hub or floating island with its own skyline would make the city feel interconnected . lighting effects are crucial . neon signs that react to movement using led technology could add some dynamism without being too bright . mirrors on buildings reflecting light like a digital canvas makes them look more alive and interactive . including technology elements , like plasma displays on walls showing info or projections onto flying cars adds depth . the city as a living organism with pulses of neon lights and moving parts gives it a life - like feel despite being man - made . in the evening , the city becomes an illuminated maze where lights dance and flicker , creating an ethereal atmosphere . at night , spaceships take off from docking stations add another dimension to the futuristic vibe . i should also consider how these elements work together . the flying cars moving through neon - lit streets with skyscrapers reflecting light creates a seamless , interconnected cityscape . the high - tech interiors enhance the futuristic theme without overwhelming the viewer . overall , this cityscape is a blend of high technology and vibrant colors that make it look both luxurious and thrilling . it 's designed to evoke an exciting environment where innovation meets entertainment . </ think > the concept of a futuristic cityscape featuring flying cars and neon lights is a classic sci - fi image that has been popularized in movies , video games , and architectural designs . here ’ s how such a cityscape might be imagined : ### 1 . ** sky as the backdrop ** - the sky would be either sunlit or at night , casting a glow on the clouds and reflecting off of birds flying overhead . - a few planes glide past in the distance , adding to the sense of air travel . ### 2 . ** the city itself ** - the city is a seamless , futuristic metropolis where architecture and technology are at their finest . - ** neon lights **: every building has neon signs that pulse and flicker in time with music or ambient sounds . the lights on the buildings could change colors , patterns , and even respond to movement ( e . g ., cars passing by ). - ** falling skies **: a thin , glowing barrier of light orbits the city at night , creating an ethereal effect . - ** sky - light **: a network of small solar - powered lamps suspended in mid - air that provide soft , diffused light to a wider area . ### 3 . ** flying cars ** - flying cars are abundant and serve as transportation throughout the city . - they come in various types : convertibles , sports cars ( with no engines but pure aerodynamics ), and cargo trucks for those who need to carry packages or people . - the exterior of these cars is covered in sleek materials that reflect the neon light . the interiors are high - tech , with glass windows displaying holographic digits while privacy screens cover sensitive information . - the tires have white led lights that glow as you ride , and the wheels spin when you brake or accelerate . ### 4 . ** car interiors ** - the seats are made of a material that seems almost liquid - like , with buttons on the dashboard that respond to touch ( e . g ., pressing them changes the car ’ s interior lights ). - the steering wheel is covered in holographic panels that show real - time data about speed , temperature , or other parameters . - seats are made from high - tech carbon fiber that can be reconfigured . ### 5 . ** the skyscraper metropolis ** - ** tall buildings **: the city ’ s skyscrapers have transparent facades that allow the neon lights to filter through and create a dazzling effect on the streets below . - ** sky - light as flying platforms **: at the top of some skyscrapers , there are platforms or landing pads where people can take off into space via flying cars . - ** central hub **: the city has a central hub or floating island that serves as a convergence point for all traffic and has its own miniature metropolis with neon - lit buildings . ### 6 . ** lighting effects ** - ** neon reactions **: neon signs react to movement , such as people walking through them ( the lights change color based on the surrounding environment ). - ** mirror reflections **: the glass exteriors of the skyscrapers reflect and refract the neon light into a kaleidoscope of patterns . - ** plasma lighting **: walls or ceilings have plasma panels that show changing colors and messages in real - time . ### 7 . ** the night city ** - at night , the city becomes an illuminated maze as lights dance and flicker in rhythm with music played by holographic performers embedded in buildings . - some areas are completely dark except for the neon lights of individual cars or buildings . ### 8 . ** higher - ledgered spaceships ** - the city is connected to outer space via a network of small , floating spaceships that orbit above ground and dock at the skyscrapers . - these spaceships have their own versions of flying cars with high - tech interiors and are constantly being serviced by shuttles from the city . ### 9 . ** interactive features ** - the neon lights on the buildings react to the presence of people , creating an interactive experience as they move through the city . - some buildings have holographic walls that project digital canvases onto them , changing with music or messages . ### 1 0 . ** the sky is the limit ** - the entire city seems to be floating on a layer of neon light , giving the impression of being part of an organism rather than a machine . - at night , the city pulses and breathes , with lights reacting to air traffic as if it were alive . this futuristic cityscape would combine high - tech elements like flying cars , advanced materials , and dynamic lighting to create a place that is both luxurious and thrilling . it would be designed to evoke excitement and wonder while also showcasing cutting - edge technology in architecture and transportation ."]
08-26
本研究基于扩展卡尔曼滤波(EKF)方法,构建了一套用于航天器姿态与轨道协同控制的仿真系统。该系统采用参数化编程设计,具备清晰的逻辑结构和详细的代码注释,便于用户根据具体需求调整参数。所提供的案例数据可直接在MATLAB环境中运行,无需额外预处理步骤,适用于计算机科学、电子信息工程及数学等相关专业学生的课程设计、综合实践或毕业课题。 在航天工程实践中,精确的姿态与轨道控制是保障深空探测、卫星组网及空间设施建设等任务成功实施的基础。扩展卡尔曼滤波作为一种适用于非线性动态系统的状态估计算法,能够有效处理系统模型中的不确定性与测量噪声,因此在航天器耦合控制领域具有重要应用价值。本研究实现的系统通过模块化设计,支持用户针对不同航天器平台或任务场景进行灵活配置,例如卫星轨道维持、飞行器交会对接或地外天体定点着陆等控制问题。 为提升系统的易用性与教学适用性,代码中关键算法步骤均附有说明性注释,有助于用户理解滤波器的初始化、状态预测、观测更新等核心流程。同时,系统兼容多个MATLAB版本(包括2014a、2019b及2024b),可适应不同的软件环境。通过实际操作该仿真系统,学生不仅能够深化对航天动力学与控制理论的认识,还可培养工程编程能力与实际问题分析技能,为后续从事相关技术研究或工程开发奠定基础。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

碧羽o(* ̄▽ ̄*)ブ回雪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值