PTA PAT乙级真题,95题(C++,AC代码)

Posted 小哈里

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PTA PAT乙级真题,95题(C++,AC代码)相关的知识,希望对你有一定的参考价值。

PAT乙级真题95题

标号标题分数通过数提交数通过率
1001害死人不偿命的(3n+1)猜想151095583091190.35
1002写出这个数20717392815630.25
1003我要通过!20374361586230.24
1004成绩排名20524301659740.32
1005继续(3n+1)猜想25355241370880.26
1006换个格式输出整数1545779915940.50
1007素数对猜想20382571575870.24
1008数组元素循环右移问题20422571315680.32
1009说反话20472571353980.35
1010一元多项式求导25359851667520.22
1011A+B 和 C15470851563540.30
1012数字分类20310861399790.22
1013数素数20326021554660.21
1014福尔摩斯的约会20254331573740.16
1015德才论25222601034590.22
1016部分A+B1535450718770.49
1017A除以B2024201846490.29
1018锤子剪刀布2024286891910.27
1019数字黑洞2023712990790.24
1020月饼2524137908670.27
1021个位数统计1527922651800.43
1022D进制的A+B2028782811410.35
1023组个最小数2026597544750.49
1024科学计数法2016829633480.27
1025反转链表2512802648530.20
1026程序运行时间1526858743560.36
1027打印沙漏2020149618110.33
1028人口普查2018830978960.19
1029旧键盘2019039545010.35
1030完美数列25183201059520.17
1031查验身份证1521205715940.30
1032挖掘机技术哪家强20303201108710.27
1033旧键盘打字2016789928610.18
1034有理数四则运算2010576424220.25
1035插入与归并259003320430.28
1036跟奥巴马一起编程1526116617820.42
1037在霍格沃茨找零钱2016929359560.47
1038统计同成绩学生2016690570850.29
1039到底买不买2015806357690.44
1040有几个PAT2514477534460.27
1041考试座位号1520440430610.47
1042字符统计2016762402680.42
1043输出PATest2015862293320.54
1044火星数字2011421442140.26
1045快速排序2511554626320.18
1046划拳1520960377510.56
1047编程团体赛2014519250920.58
1048数字加密2013900609940.23
1049数列的片段和2012190586030.21
1050螺旋矩阵258503362270.23
1051复数乘法1510987456350.24
1052卖个萌208348321240.26
1053住房空置率209566297400.32
1054求平均值209621413490.23
1055集体照257208210830.34
1056组合数的和1513031203300.64
1057数零壹209869263260.37
1058选择题207314210490.35
1059C语言竞赛208562306130.28
1060爱丁顿数258906423850.21
1061判断题1512194208180.59
1062最简分数208089387220.21
1063计算谱半径208812151000.58
1064朋友数209903221990.45
1065单身狗259010352570.26
1066图像过滤1510482295380.35
1067试密码209650513160.19
1068万绿丛中一点红206399319710.20
1069微博转发抽奖208149249700.33
1070结绳258102185230.44
1071小赌怡情159866334270.30
1072开学寄语208140224610.36
1073多选题常见计分法204868130950.37
1074宇宙无敌加法器206160276330.22
1075链表元素分类255060177730.28
1076Wifi密码1512424250330.50
1077互评成绩计算208397199860.42
1078字符串压缩与解压207723237500.33
1079延迟的回文数206654223870.30
1080MOOC期终成绩256550240970.27
1081检查密码1510744430200.25
1082射击比赛209013203340.44
1083是否存在相等的差208804219190.40
1084外观数列207137173930.41
1085PAT单位排行256512299720.22
1086就不告诉你1512075384390.31
1087有多少不同的值2010210213450.48
1088三人行208082360470.22
1089狼人杀-简单版205719121640.47
1090危险品装箱257491235490.32
1091N-自守数1510640253290.42
1092最好吃的月饼208536241220.35
1093字符串A+B2010739261590.41
1094谷歌的招聘209544436520.22
1095解码PAT准考证256117320900.19

1001

#include<iostream> 
using namespace std;
int main(){
	int n;  cin>>n;
	int cnt = 0;
	while(n != 1){
		if(n%2==0)n = n/2;
		else n = (3*n+1)/2;
		cnt++;
	}
	cout<<cnt<<'\\n';
	return 0;
}

1002

#include<iostream>
#include<string>
using namespace std;
string zm(int x){
	if(x == 0)return "ling";
	if(x == 1)return "yi";
	if(x == 2)return "er";
	if(x == 3)return "san";
	if(x == 4)return "si";
	if(x == 5)return "wu";
	if(x == 6)return "liu";
	if(x == 7)return "qi";
	if(x == 8)return "ba";
	if(x == 9)return "jiu";
}
int main(){
	string s;
	cin>>s;
	int ans = 0;
	for(int i = 0; i < s.size(); i++){
		ans += s[i]-'0';
	}
	if(ans >= 100){
		int x = ans/100;
		int y = ans/10%10;
		int z = ans%10;
		cout<<zm(x)<<' '<<zm(y)<<" "<<zm(z)<<'\\n';
	}else if(ans >= 10){
		int x = ans%10;
		int y = ans/10%10;
		cout<<zm(y)<<' '<<zm(x)<<'\\n';
	}else{
		cout<<zm(ans)<<'\\n';
	}
	return 0;
}

1003

#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int n; cin>>n;
	while(n--){
		string s; cin>>s;
		int m[500], p, t;
		memset(m,0,sizeof(m));
		for(int i = 0; i < s.size(); i++){
			m[s[i]]++;
			if(s[i]=='P')p = i;
			if(s[i]=='T')t = i;
		}
		int size = 0;
		for(int i = 'A'; i < 'z'; i++)if(m[i])size++;
		if(m['P']==1&&m['T']==1&&m['A']!=0&&size==3 &&t-p!=1&&p*(t-p-1)==s.size()-t-1)
			cout<<"YES\\n";
		else 
			cout<<"NO\\n";
	}
	return 0;
}

1004

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

struct stu{
	string name, id;
	int score;
	bool operator < (stu b){
		return score<b.score;
	}
}minn, maxx, t;

int main(){
	int n;  cin>>n;
	maxx.score = -1e9+10, minn.score = 1e9+10;
	for(int i = 1; i <= n; i++){
		cin>>t.name>>t.id>>t.score;
		if(t.score>maxx.score){
			maxx = t;
		}
		if(t.score<minn.score){
			minn = t;
		}
	}
	cout<<maxx.name<<" "<<maxx.id<<'\\n';
	cout<<minn.name<<" "<<minn.id<<'\\n';
	return 0;
}

1005

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

const int maxn = 11000;
int a[maxn], b[maxn];

const bool cmp(int a, int b){return a>b;}

void tag(int x){
	while(x!=1){
		if(x%2==0)b[x=x/2] = 1;
		else b[x=(3*x+1)/2] = 1;
	}
}

int main(){
	int n;  cin>>n;
	for(int i = 1; i <= n; i++){
		cin>>a[i];  tag(a[i]);
	}
	
	vector<int>ans;
	sort(a+1,a+n+1,cmp);
	for(int i = 1; i <= n; i++)
		if(!b[a[i]])ans.push_back(a[i]);
	for(int i = 0; i < ans.size()-1; i++)
		cout<<ans[i]<<' ';
	cout<<ans[ans.size()-1];
	return 0;
}

1006

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int n;  cin>>n;
	int a[3] = {0}, k=0;
	while(n!=0){
		a[k++]=n%10;
		n /= 10;
	}
	for(int i = 0; i < a[2]; i++)cout<<"B";
	for(int i = 0; i < a[1]; i++)cout<<"S";
	for(int i = 0; i < a[0]; i++)cout<<i+1;
	return 0;
}

1007

//求1-n有几对差为2的素数,直接枚举
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int isprime(int x){
	for(int i = 2; i*i<=x; i++)
		if(x%i==0)return false;
	return true;
}
int main(){
	int n;  cin>>n;
	int ans = 0;
	for(int i = 5; i <= n; i++)
		if(isprime(i) && isprime(i-2))
			ans++;
	cout<<ans<<"\\n";
	return 0;
}

1008

//将长为n的数组右移m位,直接枚举
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[110];
int main(){
	int n, m;  cin>>n>>m;
	for(int i = 1; i <= n; i++)cin>>a[i];
	int t = n-m%n;
	vector<int>ans;
	for(int i = t+1; i <= n; i++)ans.push_back(a[i]);
	for(int i = 1; i <= t; i++)ans.push_back(a[i]);
	for(int i = 0; i < ans.size(); i++){
		if(i!=0)cout<<" ";
		cout<<ans[i];
	}
	return 0;
}

1009

//将长为n的数组右移m位,直接枚举
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
stack<string>st;
int main(){
	string s;
	while(cin>>s)st.push(s);
	while(st.size(PAT乙级(Basic Level)真题训练

PAT乙级1044

PAT乙级全套超详细题解建议收藏

PTA乙级 (*1040 有几个PAT (25分))

PTA乙级 (*1095 解码PAT准考证 (25分))

PAT乙级满分冲刺,每日十题计划,看完直呼内行!!