跳到正文

个人记录

日记2

xxsap约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年12月12日
收录
2025年12月12日
更新
2025年12月12日
篇幅
约 2 分钟
获赞
2

版本

  1. v1当前

注:本日记分两个部分

第一部分

属于题目(无太多趣味)

欧拉计划(不知道的上网查)

做了两道


B3745

属于菜题不过多细说,直接上代码

C++
#include <bits/stdc++.h>
using namespace std;

int n,m,a[1000005],s,cnt;

int main()
{
	cin >> n >> m;
	for (int i = 1;i <= m;i++)
	{
		cin >> s;
		if (s-2 > 0 && s-2 < n+1) a[s-2] = 1;
		if (s-1 > 0 && s-1 < n+1) a[s-1] = 1;
		if (s > 0 && s < n+1) a[s] = 1;
		if (s+1 > 0 && s+1 < n+1) a[s+1] = 1;
		if (s+2 > 0 && s+2 < n+1) a[s+2] = 1;
	}
	for (int i = 1;i <= n;i++)
	{
		if (a[i] == 1) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

P9064

贪心问题

C++
#include <bits/stdc++.h>
using namespace std;

int n,m,a[100005],minn = 1e9+7;

int main()
{
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	for (int i = 1;i <= n-m+1;i++)
	{
		minn = min(minn,a[i+m-1]-a[i]);
	}
	cout << minn << endl;

	return 0;
}

happyhappy值加一

第二部分

各位客官问个问题

你有宠物吗?

有的请点个赞,没有的也请点个赞证明你来过

回到正题

我家有一只英短三花

8月3号一岁

所以是不给点什么?

礼物都给我准备上

别跑,我还没说完

再次征求大家意见

你觉得应该怎么给它过生日?(它是母猫!!!)

原文