CCF-CSP认证(202009)题目

202009-1(称检测点查询)

题目链接:

计算机软件能力认证考试系统icon-default.png?t=N7T8http://118.190.20.162/view.page?gpid=T113题意:

思路:

        利用结构体排序即可。

代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<stack>
#include<cmath>
#include<unordered_set>

#define PII pair<int, int>
#define ll long long

using namespace std;

const int N = 210;

int n, x, y;

struct pt
{
	int num, a, b;
	double dis;
} poit[N];

bool cmp(pt p1, pt p2)
{
	if(p1.dis != p2.dis)return p1.dis < p2.dis;
	else return p1.num < p2.num;
}

void solve()
{
	cin >> n >> x >> y;
	
	for (int i = 1; i <= n; ++ i)
	{
		poit[i].num = i;
		cin >> poit[i].a >> poit[i].b;
		poit[i].dis = pow(x - poit[i].a, 2) + pow(y - poit[i].b, 2);
	}
	
	sort(poit + 1, poit + n + 1, cmp);
	
	for (int i = 1; i <= 3; ++ i) cout << poit[i].num << endl;
}

signed main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
//	int T;
//	cin >> T;
//	
//	while(T--)
//	{
		solve();
//	}
	
	return 0;
}

202009-2(风险人群筛查)

题目链接:
计算机软件能力认证考试系统icon-default.png?t=N7T8http://118.190.20.162/view.page?gpid=T112

题意:

思路:
        本题就是一个逐一判断坐标是否位于“高危”区内,如果有一次位于过,那么就是经过,如果连续处于超过k,那就是逗留,比较坑的点在于必须是连续的处于才算,所以只需要设置一个is的布尔变量来判断就行,每次连续的开头将is置true,结尾将is置false并且更新最大连续数,最后根据k判断即可。

代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<stack>
#include<cmath>
#include<unordered_set>

#define PII pair<int, int>
#define ll long long

using namespace std;

const int N = 110;

int n, k, t, xl, yd, xr, yu;
int x, y;
int guo, liu;

void solve()
{
	cin >> n >> k >> t >> xl >> yd >> xr >> yu;
	
	int sum = 0, ma = 0;
	
	for (int op = 0; op < n; ++ op)
	{
	    ma = 0, sum = 0;
		bool is = false;
		for (int i = 0; i < t; ++ i)
		{
			cin >> x >> y;
			
			if(x >= xl && x <= xr && y >= yd && y <= yu)
			{
			    if(!is) 
			    {
			        is = true;
			        sum = 0;
			    }
			    ++ sum;
			}
			else 
			{
			    ma = max(ma, sum);
			    is = false;
			}
		}
		
		ma = max(sum, ma);
		
		if(ma > 0 && ma < k) guo ++;
		else if(ma >= k) guo ++, liu ++;
	}
	
	cout << guo << endl;
	cout << liu << endl;
}

signed main()
{
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
//	int T;
//	cin >> T;
//	
//	while(T--)
//	{
		solve();
//	}
	
	return 0;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Dawpro_加薪

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

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

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

打赏作者

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

抵扣说明:

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

余额充值