pat-advanced(1035-1038)

本文探讨了深度学习技术在音视频处理、音视频直播、图像处理AR特效等领域的应用,包括图像色彩空间、视频编解码算法、音频编解码算法、视频容器、FFmpeg音视频编解码、硬件编解码、音频处理滤波等方面的应用实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1035. Password (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One solution is to replace 1 (one) by @, 0 (zero) by %, l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N (<= 1000), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.

Output Specification:

For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line "There are N accounts and no account is modified" where N is the total number of accounts. However, if N is one, you must print "There is 1 account and no account is modified" instead.

Sample Input 1:

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa
Sample Output 1:
2
Team000002 RLsp%dfa
Team000001 R@spodfa
Sample Input 2:
1
team110 abcdefg332
Sample Output 2:
There is 1 account and no account is modified
Sample Input 3:
2
team110 abcdefg222
team220 abcdefg333
Sample Output 3:
There are 2 accounts and no account is modified

//1035
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;

struct member {
	char name[11];
	char passw[11];
};

member mems[1005];

int main()
{
	int N;
	scanf("%d", &N);
	int n = 0;
	vector<int> order;
	getchar();

	int i;
	for(i = 0; i < N; i++)
	{
		scanf("%s %s",mems[i].name, mems[i].passw);
		getchar();

		int len = strlen(mems[i].passw);
		int j;
		int m = 0;
		for(j = 0; j < len; j++)
		{
			switch(mems[i].passw[j])
			{
				case '1':
					mems[i].passw[j] = '@';
					m = 1;
					break;
				case '0':
					mems[i].passw[j] = '%';
					m = 1;
					break;
				case 'l':
					mems[i].passw[j] = 'L';
					m = 1;
					break;
				case 'O':
					mems[i].passw[j] = 'o';
					m = 1;
					break;
				default:
					break;
			}
		}
		if(m == 1)
			order.push_back(i);
	}

	if(order.empty())
	{
		if(N == 1)
			printf("There is %d account and no account is modified\n", N);
		else
			printf("There are %d accounts and no account is modified\n", N);
	}
	else
	{
		printf("%d\n", order.size());
		for(i = 0; i < order.size(); i++)
		{
			int j = order[i];
			printf("%s %s\n", mems[j].name, mems[j].passw);
		}
	}

	return 0;
}


1036. Boys vs Girls (25)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student's name, gender, ID and grade, separated by a space, where name and ID are strings of no more than 10 characters with no space, gender is either F (female) or M (male), and grade is an integer between 0 and 100. It is guaranteed that all the grades are distinct.

Output Specification:

For each test case, output in 3 lines. The first line gives the name and ID of the female student with the highest grade, and the second line gives that of the male student with the lowest grade. The third line gives the difference gradeF-gradeM. If one such kind of student is missing, output "Absent" in the corresponding line, and output "NA" in the third line instead.

Sample Input 1:

3
Joe M Math990112 89
Mike M CS991301 100
Mary F EE990830 95
Sample Output 1:
Mary EE990830
Joe Math990112
6
Sample Input 2:
1
Jean M AA980920 60
Sample Output 2:
Absent
Jean AA980920
NA

//1036
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

struct stu {
	char name[11];
	char gender;
	char id[11];
	int grade;
};

stu stus[100001];

int main()
{
	int N;
	scanf("%d", &N);
	getchar();

	int i;
	for(i = 0; i < N; i++)
	{
		scanf("%s %c %s %d", stus[i].name, &stus[i].gender, stus[i].id, &stus[i].grade);
		getchar();
	}

	int lowest_m = 101;
	int highest_f = -1;
	int x = -1, y = -1;

	for(i = 0; i < N; i++)
	{
		if(stus[i].gender == 'M')
		{
			if(stus[i].grade < lowest_m)
			{
				lowest_m = stus[i].grade;
				x = i;
			}
		}
		else
		{
			if(stus[i].grade > highest_f)
			{
				highest_f = stus[i].grade;
				y = i;
			}
		}
	}

	if(y != -1)
		printf("%s %s\n", stus[y].name, stus[y].id);
	else
		printf("Absent\n");

	if(x != -1)
		printf("%s %s\n", stus[x].name, stus[x].id);
	else
		printf("Absent\n");

	if(x != -1 && y != -1)
		printf("%d\n", stus[y].grade - stus[x].grade);
	else
		printf("NA\n");

	return 0;
}


1037. Magic Coupon (25)

时间限制
100 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop also offers some bonus product for free. However, if you apply a coupon with a positive N to this bonus product, you will have to pay the shop N times the value of the bonus product... but hey, magically, they have some coupons with negative N's!

For example, given a set of coupons {1 2 4 -1}, and a set of product values {7 6 -2 -3} (in Mars dollars M$) where a negative value corresponds to a bonus product. You can apply coupon 3 (with N being 4) to product 1 (with value M$7) to get M$28 back; coupon 2 to product 2 to get M$12 back; and coupon 4 to product 4 to get M$3 back. On the other hand, if you apply coupon 3 to product 4, you will have to pay M$12 to the shop.

Each coupon and each product may be selected at most once. Your task is to get as much money back as possible.

Input Specification:

Each input file contains one test case. For each case, the first line contains the number of coupons NC, followed by a line with NC coupon integers. Then the next line contains the number of products NP, followed by a line with NP product values. Here 1<= NC, NP <= 105, and it is guaranteed that all the numbers will not exceed 230.

Output Specification:

For each test case, simply print in a line the maximum amount of money you can get back.

Sample Input:
4
1 2 4 -1
4
7 6 -2 -3
Sample Output:
43

//1037
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

long long couple[100001];
long long product[100001];

int main()
{
	int NC, NP;
	scanf("%d", &NC);

	int i;
	for(i = 0; i< NC; i++)
		scanf("%lld", &couple[i]);
	scanf("%d", &NP);
	for(i = 0; i< NP; i++)
		scanf("%lld", &product[i]);
	
	long long max_v = 0;

	sort(couple, couple + NC);

	sort(product, product + NP);
	int i1 = 0, i2 = NC - 1;
	int j1 = 0, j2 = NP - 1;

	while(i1 <= i2 && j1 <= j2)
	{
		if(couple[i1]<0 && product[j1]<0)
			max_v += couple[i1] * product[j1];
		else
			break;
		i1++;j1++;
	}

	while(i2>=0 && j2>=0)
	{
		if(couple[i2]>0 && product[j2]>0)
			max_v += couple[i2] * product[j2];
		else
			break;
		i2--;j2--;
	}

	printf("%lld\n", max_v);
	return 0;
}


1038. Recover the Smallest Number (30)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 with respect to different orders of combinations of these segments, and the smallest number is 0229-321-3214-32-87.

Input Specification:

Each input file contains one test case. Each case gives a positive integer N (<=10000) followed by N number segments. Each segment contains a non-negative integer of no more than 8 digits. All the numbers in a line are separated by a space.

Output Specification:

For each test case, print the smallest number in one line. Do not output leading zeros.

Sample Input:
5 32 321 3214 0229 87
Sample Output:
22932132143287

//1038
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
using namespace std;

bool cmp(string a, string b)
{
	return (a+b) < (b+a);
}

int main()
{
	int N;
	cin>> N;
	vector<string> input(N);

	int i;
	for(i = 0; i< N;i++)
	{
		cin>> input[i];
	}

	sort(input.begin(), input.end(), cmp);
	int flag = 0;
	for(i = 0; i < N; i++)
	{
		if(flag == 0)
		{
			int j = 0;
			while(j < input[i].size() &&input[i][j] == '0')
				j++;

			if(j < input[i].size())
			{
				cout<<input[i].substr(j, input[i].size()-j);
				flag = 1;
			}
		}
		else
			cout<< input[i];
	}

	if(flag == 0)
		cout<< "0";
	cout<< endl;
	return 0;
}




内容概要:本文档详细介绍了基于MATLAB实现多目标差分进化(MODE)算法进行无人机三维路径规划的项目实例。项目旨在提升无人机在复杂三维环境中路径规划的精度、实时性、多目标协调处理能力、障碍物避让能力和路径平滑性。通过引入多目标差分进化算法,项目解决了传统路径规划算法在动态环境和多目标优化中的不足,实现了路径长度、飞行安全距离、能耗等多个目标的协调优化。文档涵盖了环境建模、路径编码、多目标优化策略、障碍物检测与避让、路径平滑处理等关键技术模块,并提供了部分MATLAB代码示例。 适合人群:具备一定编程基础,对无人机路径规划和多目标优化算法感兴趣的科研人员、工程师和研究生。 使用场景及目标:①适用于无人机在军事侦察、环境监测、灾害救援、物流运输、城市管理等领域的三维路径规划;②通过多目标差分进化算法,优化路径长度、飞行安全距离、能耗等多目标,提升无人机任务执行效率和安全性;③解决动态环境变化、实时路径调整和复杂障碍物避让等问题。 其他说明:项目采用模块化设计,便于集成不同的优化目标和动态环境因素,支持后续算法升级与功能扩展。通过系统实现和仿真实验验证,项目不仅提升了理论研究的实用价值,还为无人机智能自主飞行提供了技术基础。文档提供了详细的代码示例,有助于读者深入理解和实践该项目。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值