PAT

2024/4/11 18:28:26

卡拉兹(Callatz)猜想(以VS2017为例)

前言: 我是个普通二本的学生,想学习算法去参加PAT。我将在这里记录下我的学习路程。在这里我将用VS2017作为学习环境。C语言的知识我只停留在课本,我主要学习的语言是Java,但是众所周知C和C的效率Java远远跟不上。所以在Pa…

A+B和C(PAT乙级B1011)

题目描述 给定区间[-2^31,2^31]内的三个整数A,B和C,请判断AB是否大于C。 输入格式 第 1 行给出正整数 T (≤10),即测试用例的个数。随后给出 T 组测试用例,每组占一行,顺序给出 A、B 和 C。整数间以空格分隔。 输出格式 对每…

PAT A 1142 AC代码

最大点数就200&#xff0c;可以放心地嵌套循环、 按照判断依据写就好了&#xff0c;注意一下判断的逻辑就行 #include<iostream> #include<vector> using namespace std; int edge[201][201]{0}; int Nv,Ne,M,K; int main(){cin>>Nv>>Ne;for(int i0;…

PAT A 1150 AC代码

存储好数据后根据条件逐一判断即可。注意一下各种输出格式。 #include<iostream> #include<vector> #include<algorithm> using namespace std; int dis[201][201]; int N,M,K,min_num0,Min1000000000; int main(){cin>>N>>M;fill(dis[0],dis[0…

1140 Look-and-say Sequence (20 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1140 Look-and-say Sequence&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; 无 题目翻译&#xff1a; Look-and-say 是…

PAT:A除以B

题目描述 本题要求计算A/B&#xff0c;其中A是不超过1000位的正整数&#xff0c;B是1位正整数。你需要输出商数Q和余数R&#xff0c;使得A B * Q R成立。 输入描述: 输入在1行中依次给出A和B&#xff0c;中间以1空格分隔。 输出描述: 在1行中依次输出Q和R&#xff0c;中…

PAT甲级答案一览表(持续更新)_Pooooooocky

为方便汇总学习&#xff0c;本篇博文记录PAT甲级题目的全部答案链接&#xff1a; 每道题目都会有「中文翻译」、「题目解析」和详细的「逻辑分析」并附上「参考代码」。 若想按照「PAT知识点分类」进行学习&#xff0c;请看另一篇博文&#xff08;点此跳转&#xff09;。 10…

1152 Google Recruitment (20 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1152 Google Recruitment&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; string 头文件函数 substr() 截取字符串子串&a…

【PAT刷题甲级】1090.Highest Price in Supply Chain

1090 Highest Price in Supply Chain (25 分) A supply chain is a network of retailers&#xff08;零售商&#xff09;, distributors&#xff08;经销商&#xff09;, and suppliers&#xff08;供应商&#xff09;-- everyone involved in moving a product from supplie…

【PAT刷题甲级】1062.Talent and Virtue

1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people’s talent and virtue. According to his theory, a man being outstanding in both talent and virtue must be a “sage&…

PAT A 1148 AC代码(两种可行思路和代码)

应该是20分题里面容易出问题的题目了。 思路一&#xff08;可行但是复杂&#xff0c;不推荐&#xff0c;推荐下面的思路二&#xff09;&#xff1a; &#xff08;可以帮助这个思路写但是测试点3不过的同学&#xff0c;因为现实中解这种问题可能更多先想到这思路&#xff09; …

PAT A 2019年秋 7-1 Forever AC代码

这道题很搞心态&#xff0c;用了素数判断、最大公约数以及各数位求和&#xff08;分别写为了3个函数&#xff09; 但是对范围内的数字进行暴力遍历的话&#xff0c;最后两个测试点会超时 需要根据测试结果想到所有满足条件的数都是以99结尾&#xff0c;这样只遍历99结尾的数才…

【PAT甲级 - C++题解】1048 Find Coins

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4da;专栏地址&#xff1a;PAT题解集合 &#x1f4dd;原题地址&#xff1a;题目详情 - 1048 Find Coins (pintia.cn) &#x1f511;中文翻译&#xff1a;找硬币 &#x1f4e3;专栏定位…

【PAT刷题甲级】部分笔记1001-1064~(上)

写在前面 这里C菜鸟一枚~ 暑假将近两个月刷PAT甲级的笔记在此&#xff0c;虽然最终也没有取得满意的结果&#xff0c;但是不可否认&#xff0c;还是从中学到了很多&#xff0c;是我准备的还不够充分&#xff0c;希望能给刷题的同学们一些帮助。 PS&#xff1a;不是每道题都有&…

1053 Path of Equal Weight (30 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1053 Path of Equal Weight&#xff08;30分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; C STL vectorC STL sort()函数 题目翻译&am…

【PAT刷题甲级】1117.Eddington Number

1117 Eddington Number (25 分) British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an “Eddington number”, E – that is, the maximum integer E such that it is for E days that one rides mor…

PAT 1041 Linked List Sorting (25)(链表排序)

题目 1052. Linked List Sorting (25)时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contai…

PAT 1047 To Fill or Not to Fill (25)(高速公路加油问题)

题目 1033. To Fill or Not to Fill (25)时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 ZHANG, Guochuan With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limi…

PAT 1005 Spell It Right (20)(字符转换)

题目 1005. Spell It Right (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in …

PAT 1033 Shopping in Mars (25)(子序列)

题目 1044. Shopping in Mars (25)时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$…

1115 Counting Nodes in a BST (30 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1115 Counting Nodes in a BST&#xff08;30分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; 二叉树排序树的基本知识 题目翻译&#xff1a; 二叉搜索树&#xff08;BST&#xf…

1090 Highest Price in Supply Chain (25 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1090 Highest Price in Supply Chain&#xff08;25分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; 二叉树的深度优先搜索 题目翻译&#xff1a; 供应链是一个由零售商、经销商和…

【PAT刷题甲级】1102.Invert a Binary Tree

1102 Invert a Binary Tree (25 分) The following is from Max Howell twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you cant invert a binary tree on a whiteboard so fuck off.Now it’s your turn to prove that YOU CAN invert…

【PAT刷题甲级】1100.Mars Numbers

1100 Mars Numbers (20 分) People on Mars count their numbers with base 13: Zero on Earth is called “tret” on Mars. The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively. For the next…

PAT A 1143 AC代码(BST树LCA问题算法详解)

这题可以结合1151来学习理解。 首先要知道BST树中序序列即数据点增序序列。 &#xff08;所以原本基于中序顺序的比较就可以转为点的大小比较&#xff09; BST树LCA解法思路理解&#xff08;画个树就很好理解了)&#xff1a; 确保U、V均存在于树上后 从根结点开始 1、若当…

1108 Finding Average (20 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1108 Finding Average&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; strcmp() 函数&#xff1a;对比两个字符串&#x…

PAT 1030 Be Unique (20)

思路 1.简单题&#xff0c;map统计个数&#xff0c;vector<int> a(n),a(n)用来”先序“输出。 我出错的一些点 1.忘记输出为”None“的情况了。 代码 #include<iostream> #include<vector> #include <map>using namespace std;int main() {int n;map&…

【PAT刷题甲级】1115.Counting Nodes in a BST

1115 Counting Nodes in a BST (30 分) A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than or equal to the node’s key. The right subtree …

PAT 1004. Counting Leaves (30)(BFS)

题目 1004. Counting Leaves (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. In…

c++的getline函数

当你需要将输入的一行字符串保存到string变量中时 /*如果在getline前面用cin&#xff0c;请在获取字符串之前&#xff0c;先使用一次getline(cin, pwd);把cin留下的换行符获取掉 */ //pwd:string 变量 //cin:标准输入流 getline(cin, pwd); 当你需要将输入的一行字符串保存到…

PAT 1012. The Best Rank (25)(成绩排名与浮点数比较)

题目 1012. The Best Rank (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Progr…

【PAT刷题甲级】1110.Complete Binary Tree

1110 Complete Binary Tree (25 分) Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) which is the total numb…

1061 Dating (20 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1061 Dating&#xff08;20 分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;思路分析&#xff1a;参考代码预备知识&#xff1a; cctype头文件使用方法&#xff08;这是一个与字符处理有关的头文件&#xff0c;它包含了一系…

1008 数组元素循环右移问题 (20 分)

一个数组A中存有N&#xff08;>0&#xff09;个整数&#xff0c;在不允许使用另外数组的前提下&#xff0c;将每个整数循环向右移M&#xff08;≥0&#xff09;个位置&#xff0c;即将A中的数据由&#xff08;A​0​​A​1​​⋯A​N−1​​&#xff09;变换为&#xff08;A…

PAT 1010. Radix (25)(进制转化)(暂无)

题目 1010. Radix (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a pair of positive integers, for example, 6 and 110, can this equation 6 110 be true? The answer is “yes”, if 6 is a decimal…

【PAT刷题甲级】1050.String Subtraction

1050 String Subtraction (20 分) Given two strings S1 and S2 , SS1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1−S2 for any given strings. However, it might not be that simple …

PAT 1063 Count PAT's (25)

题目 1063 Count PAT’s (25) 解题思路 1.求出输入字符串s的第i个字母左边的P的个数p[i]和右边的T的个数 t[i] &#xff0c;然后再遍历s&#xff0c;如果s[i]A&#xff0c;那么用这个A能组成p[i] * t[i]个PAT&#xff0c;最后把所有的相加起来就可以了。2.sum可能很大&#x…

PAT 1061 Insert or Merge (25)

题目 1061 Insert or Merge (25) 解题思路 1.其实这种题不记得这些排序了根据题目也可以做出来。2.判断。如果是插入排序&#xff0c;则要求找到一个数比后面的数大后&#xff0c;那么就证明这个数后面的都没排好续&#xff0c;如题目中1 2 3 7 8 5 9 4 6 0&#xff0c;这里8…

PAT 1031 Shuffling Machine (20)

题目 题目描述 Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuf…

【PAT刷题甲级】1079.Total Sales of Supply Chain

1079 Total Sales of Supply Chain (25 分) A supply chain is a network of retailers&#xff08;零售商&#xff09;, distributors&#xff08;经销商&#xff09;, and suppliers&#xff08;供应商&#xff09;-- everyone involved in moving a product from supplier …

PAT 1021 Set Similarity (25)

思路 1.首先要知道c里面有个set&#xff0c;他可以保存不重复的数字&#xff0c;这样就好办多了&#xff0c;set数组的用法为&#xff1a;set<int> a[52]。2.接着要找出里面相同的项,对于在u中取出的每个数&#xff0c;然后再v中去找&#xff0c;看能不能找到&#xff0c…

PAT甲级真题 1067 Sort with Swap(0, i) (25分) C++实现(注意测试点1、2超时问题)

题目 Given any permutation of the numbers {0, 1, 2,…, N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2, 1, 3} we may apply the swap operations in the fo…

C语言—— PAT 乙级【1062 最简分数 (20分)】 + 测试点 2 分析

一、题目 一个分数一般写成两个整数相除的形式&#xff1a;N/M&#xff0c;其中 M 不为0。最简分数是指分子和分母没有公约数的分数表示形式。 现给定两个不相等的正分数 N​1​​/M​1​​ 和 N​2​​/M​2​​&#xff0c;要求你按从小到大的顺序列出它们之间分母为 K 的最…

PAT甲级真题 1066 Root of AVL Tree (25分) C++实现(建立AVL树)

题目 An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property. Figures 1-4 illust…

【PAT刷题甲级】1116.Come on! Let‘s C

1116 Come on! Let’s C (20 分) “Let’s C” is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as the following: 0、 …

1077 Kuchiguse (20 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1077 Kuchiguse&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; getline() 和 get() 的使用方法。reverse() 反转字符串的…

1106 Lowest Price in Supply Chain (25 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

此题与1090 Highest Price in Supply Chain (25 分)极为相似&#xff0c;详细解析请戳链接。 1106 Lowest Price in Supply Chain&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识…

【PAT刷题甲级】1030.Travel Plan

1030 Travel Plan (30 分) A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path between his/her starting city …

【PAT刷题甲级】1141.PAT Ranking of Institutions

1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of institutions based on their students’ performances. Now you are asked to generate the ranklist. Input Specification Each input file contains one test c…

【PAT刷题甲级】1028.List Sorting

1028 List Sorting (25 分) Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification Each input file contains one test case. For each case, the first line contains two integers N (≤10 ^5 ) and C, …

【PAT刷题甲级】1149.Dangerous Goods Packaging

1149 Dangerous Goods Packaging (25 分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent &#xff08;氧化剂&am…

【PAT甲级 - C++题解】1145 Hashing - Average Search Time

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4da;专栏地址&#xff1a;PAT题解集合 &#x1f4dd;原题地址&#xff1a;题目详情 - 1145 Hashing - Average Search Time (pintia.cn) &#x1f511;中文翻译&#xff1a;期终成绩 …

【PAT刷题甲级】1059.Prime Factors

1059 Prime Factors (25 分) Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N p1^k1p2 ^k2⋯pm ^km. Input Specification Each input file contains one test case which gives a positive integer N …

【PAT刷题甲级】1054.The Dominant Color

1054 The Dominant Color (20 分) Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the dominant color. A stric…

【PAT刷题甲级】1106.Lowest Price in Supply Chain

1106 Lowest Price in Supply Chain (25 分) A supply chain is a network of retailers&#xff08;零售商&#xff09;, distributors&#xff08;经销商&#xff09;, and suppliers&#xff08;供应商&#xff09;-- everyone involved in moving a product from supplier…

PAT 1011. World Cup Betting (20)(浮点数乘法)

题目 1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players …

德才论 (25)

时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”&#xff1a;“是故才德全尽谓之圣人&#xff0c;才德兼亡谓之愚人&#xff0c;德胜才谓之君子&#xff0c;才胜德…

【PAT刷题甲级】1055.The World‘s Richest

1055 The World’s Richest (25 分) Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain range…

PAT 1027 Speech Patterns (25)

思路 1.分词&#xff0c;用char[]储存输入数据&#xff0c;gets(a)输入一行数据&#xff0c;ssa(i)//(string 的性质)划分并组合成单词。2.统计&#xff0c;用map<string,int>统计数据即可。 自己出错的地方 1.char a[]是用gets(a)输入&#xff0c;不是cin>>a&…

PAT 1013 Battle Over Cities

个人学习记录&#xff0c;代码难免不尽人意。 It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair a…

PAT 1023 A+B and C (64bit) (20)

思路 1.long 32 (-2^8,2^8-1); longlong 64 (-2^32,2^32-1&#xff09;; long double 128 (-2^127,2^127-1); 我出错的一些点 1.不熟悉这些范围 代码 #include<iostream>using namespace std;int main() {long double a, b, c;int n;cin >> n;for (int i 0; i &l…

PAT 1025 Sort with Swap(0,*) (25)

思路 1.其实很简单&#xff0c;找到0放在哪个位置上&#xff0c;如果0就放在0的位置上&#xff0c;则找出后面的第一个出错的位置与之交换即可&#xff0c;如果0不在0的位置上&#xff0c;则把0与该应该在该位置上的点交换即可。2.对于0不在0的位置上&#xff0c;例如&#xff…

1086 Tree Traversals Again (25 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1086 Tree Traversals Again&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; 二叉树前序和中序转后序算法 题目翻译&…

PAT Counting Ones (30)

题目 题目描述 The task is simple: given any positive integer N, you are supposed to count the total number of 1s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1s in 1, 10, 11, and 12.输入描述: Each input f…

PAT 1001. A+B Format (20)(字符串转换)

题目 1001. AB Format (20)时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Calculate a b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are…

PAT甲级真题 1105 Spiral Matrix (25分) C++实现(画螺旋矩阵)

题目 This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in a clockwise spiral. The matrix has m rows and n co…

数素数 (20)

时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 令Pi表示第i个素数。现任给两个正整数M < N < 10000&#xff0c;请输出PM到PN的所有素数。 输入描述: 输入在一行中给出M和N&#xff0c;其间以空格分隔。 输出描述…

1102 Invert a Binary Tree (25 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1102 Invert a Binary Tree&#xff08;25分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; stoi() 函数的用法&#xff1b;DFS中序遍历二叉树&#xff1b;用结构体数组存储二叉树。…

PAT甲级答案一览表(按题目分类 | 持续更新)_Pooooooocky

2021年4月3日开贴&#xff0c;持续更新中……&#xff08;每周更新约3题&#xff09; 若想直接按题号查看「PAT答案一览表」请跳转至另一篇博文&#xff08;点此跳转&#xff09; PAT甲级题目分类 水题&#xff1a; 1136113911431148… …… …… …… …… …… … 字符串…

PAT甲级真题 1092 To Buy or Not to Buy (20分) C++实现(vector模拟map统计元素数量)

题目 Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in whole pieces. Hence Eva must check…

C语言—— PAT 乙级【1060 爱丁顿数 (25分)】

一、题目 & 运行结果 英国天文学家爱丁顿很喜欢骑车。据说他为了炫耀自己的骑车功力&#xff0c;还定义了一个“爱丁顿数” E &#xff0c;即满足有 E 天骑车超过 E 英里的最大整数 E。据说爱丁顿自己的 E 等于87。 现给定某人 N 天的骑车距离&#xff0c;请你算出对应的…

PAT甲级真题 1094 The Largest Generation (25分) C++实现(树的层序遍历,统计各层节点数)

题目 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Input Specification: Each input file contains one test cas…

PAT 1002. A+B for Polynomials (25)(多项式加法)(待修改)

题目 1002. AB for Polynomials (25)时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This time, you are supposed to find AB where A and B are two polynomials.InputEach input file contains one test case. Each case occup…

PAT 1037 Find Coins (25)(dp子序列)

题目 1048. Find Coins (25)时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall w…

PAT 1059 Perfect Sequence (25)(dp完美序列)

题目 1059 Perfect Sequence (25) 解题思路 1.先排序然后找出每个点的最大长度。2.对于起点i&#xff0c;假设循环找到的最后一个满足条件的位置 j > i,那么对于起点为 i1 &#xff0c;j也会满足&#xff0c;例如排好序后序列为&#xff1a;1 2 3 4 5 6 7 8 9 20,p 8,对于…

PAT 1050 Course List for Student (25)(选课)

题目 1039. Course List for Student (25)时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are s…

1016. 部分A+B (15)

时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 正整数A的“DA&#xff08;为1位整数&#xff09;部分”定义为由A中所有DA组成的新整数PA。例如&#xff1a;给定A 3862767&#xff0c;DA 6&#xff0c;则A的“6部分”PA…

【PAT刷题甲级】部分笔记1065-1155~(下)

写在前面 接上篇【PAT刷题甲级】部分笔记1001-1064~&#xff08;上&#xff09; 这里是1065-1155&#xff0c;同样仅为本人刷的题部分笔记&#xff0c;不包括所有题&#xff0c;希望对刷题的同学有帮助~ 上篇&#xff1a;【PAT刷题甲级】部分笔记1001-1064~&#xff08;上&…

PAT甲级真题 1114 Family Property (25分) C++实现 (并查集)

题目 This time, you are supposed to help us collect the data for family-owned property. Given each person’s family members, and the estate&#xff08;房产&#xff09;info under his/her own name, we need to know the size of each family, and the average ar…

PAT甲级真题 1087 All Roads Lead to Rome (30分) C++实现(Dijkstra+DFS,带权无向图最优最短路径)

题目 Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness. Input Specification: Each input file contains one test case. For each case, the…

PAT甲级真题 1113 Integer Set Partition (25分) C++实现 (简单划分数组)

题目 Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote the sums of all the numbers in A1 and A2, respectively. You are supposed to make …

PAT 2019年冬 7-2 Block Reversing AC代码

用algorithm中的reverse函数比较方便 #include<iostream> #include<vector> #include<algorithm> using namespace std; int start,N,K; vector<int> L,ans; int cnt0; struct node{int data,next; }Node[100000]; void trail(int index){if(index-1) …

PAT:数字分类

题目描述 给定一系列正整数&#xff0c;请按要求对数字进行分类&#xff0c;并输出以下5个数字&#xff1a; A1 能被5整除的数字中所有偶数的和&#xff1b; A2 将被5除后余1的数字按给出顺序进行交错求和&#xff0c;即计算n1-n2n3-n4…&#xff1b; A3 被5除后余2的数…

PAT A 2019年秋季 7-4 Dijkstra Sequence AC代码

一道dijkstra算法的模板题 对于所谓的Dijkstra Sequence&#xff0c;直接判断给出结点序列到起点距离(d[x])是否是不严格增序(<)即可&#xff0c;这样只需要用模板&#xff0c;再判断距离是否不严格递增即可。 对于这一点&#xff0c;我的理解是&#xff1a; 根据dijkstr…

PAT A 2019年秋 7-2 Merging Linked Lists AC代码

我就按照题目意思&#xff0c;先用结构体记录链表&#xff0c;然后遍历短的&#xff08;go1函数&#xff09;&#xff08;先从b1跑一遍&#xff0c;如果记录下的数量>N/2,说明b1开始的是长的&#xff0c;那么就重新跑a1&#xff09;&#xff0c;记录下短的地址顺序&#xff…

PAT A 1151 AC代码(LCA问题的通法思路)

这题可以结合1143来学习理解。 树LCA解法通法思路&#xff1a; 确保U、V均存在于树上后 从根结点开始 1、若当前结点index的中序位置在U&#xff0c;V的中序位置之间&#xff0c;则当前结点index就是U、V的LCA 2、若U、V的中序位置均小于index的中序位置&#xff0c;index…

PAT A 2019春 7-3 Telefraud Detection AC代码

题目稍微有点复杂 最好用并查集&#xff0c;形成gang 第一次写输出的时候看错题目了&#xff0c;题目只要求按照gang的首个数字大小输出&#xff0c;不要求按照gang的人数排序&#xff0c;读题目要再小心一点 #include<iostream> #include<vector> using namespa…

PAT甲级真题 1107 Social Clusters (30分) C++实现(并查集:路径压缩+优先级)

题目 When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set of people who have some of their hobbies in common. You are supposed to find all t…

PAT A 1149 AC代码(散列,两种解法)

解法一&#xff1a; 用一个map<int,vector<int>> G 标记每个物品对应的不相容物品 引入一个ban数组&#xff0c;用来标记出现到第j个物品时&#xff0c;都有哪些物品不能出现&#xff0c;如果第j个物品可以出现&#xff0c;将其不相容物品在ban中标记为1&#xf…

PAT A 1153 AC代码(耗时100ms以内)

在这种数据处理复杂并且可能输出较多的情况下 &#xff01;&#xff01;&#xff01;牢记&#xff1a;多次读取&#xff0c;多次输出的地方&#xff08;循环中&#xff09;&#xff0c;能用scanf和printf就不要用cin和cout 这道题就是典型的换输出方法会导致耗时非常显著变化…

PAT A 1146 AC代码

拓扑排序的简单模拟 都不需要用队列 只需要按照顺序&#xff0c;判断入度是否为0即可&#xff08;过程中指向点的入度要跟着减少&#xff09; #include<iostream> #include<vector> using namespace std; struct node{int in;vector<int> cl; }; int N,M,K…

PAT A 1154 AC代码

根据给出的颜色判断一下每条边两端是否是不同颜色就好了。简单题 #include<iostream> #include<vector> #include<set> using namespace std; vector<int> edge; int N,M,K; int main(){cin>>N>>M;edge.resize(2*M);for(int i0;i<M;i)…

PAT A 1155 AC代码(堆的遍历,路径记录)

check函数遍历堆&#xff0c;用path记录路径&#xff0c;在遍历到叶结点&#xff08;叶结点条件&#xff1a;2*index>N) 时输出。 遍历的时候顺便比较一下父子大小判断是大顶堆还是小顶堆 #include<iostream> #include<vector> using namespace std; int N; v…

PAT A 2019年春 7-2 Anniversary AC代码

用了一个set记录校友&#xff0c;读取来宾的时候做两件事&#xff1a; 1、判断是否是校友&#xff0c;是则ans1 2、判断是否是最年长的&#xff0c;是则更新ans2和生日最小值 #include<iostream> #include<set> #include<algorithm> using namespace std; …

PAT A 2019春 7-4 Structure of a Binary Tree AC代码

一开始看到题目的时候有点懵&#xff0c;这个输入有点让人头大 按照种类不断细分来写&#xff0c;对于每个输入一个一个词读取判断 还有就是根据后序和中序建树&#xff0c;为方便判断结构体多存一点信息 我根据后序的顺序对每个数字编号&#xff0c;用了一个map记录对应关系…

PAT A 2019年秋季 7-3 Postfix Expression AC代码

对于如题给出的语法树&#xff0c;每个结点只有三种情况&#xff1a; 1、左子不空&#xff0c;右子不空 2、左子空&#xff0c;右子不空 3、左子空&#xff0c;右子空 根据题意&#xff0c;对应的输出应为 1、&#xff08; 左子树内容 右子树内容 当前结点内容 &#xff0…

PAT 2019年冬 7-3 Summit AC代码

对于每个人&#xff0c;我用了一个set记录他的好友 #include<iostream> #include<vector> #include<set> using namespace std; static set<int> s[210]; static set<int> f; int N,M,K; int main(){cin>>N>>M;for(int i0;i<M;i…

PAT A 2020年冬 7-1 The Closest Fibonacci Number AC代码

7-1 The Closest Fibonacci Number (20 分) The Fibonacci sequence Fn​ is defined by Fn2​Fn1​Fn​ for n≥0, with F0​0 and F1​1. The closest Fibonacci number is defined as the Fibonacci number with the smallest absolute difference with the given integer …

【PAT刷题甲级】1058.A+B in Hogwarts

1058 AB in Hogwarts (20 分) If you are a fan of Harry Potter, you would know the world of magic has its own currency system – as Hagrid explained it to Harry, “Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it’s easy enough.”…

PTA L1-8 静静的推荐

PTA L1-8 静静的推荐 分数 20 全屏浏览题目 切换布局 作者 陈越 单位 浙江大学 天梯赛结束后&#xff0c;某企业的人力资源部希望组委会能推荐一批优秀的学生&#xff0c;这个整理推荐名单的任务就由静静姐负责。企业接受推荐的流程是这样的&#xff1a; 只考虑得分不低于 175 …

记PAT 甲级 2021年 秋季考试 经验总结、线上考试细节、考场题解

1、简单回顾 今天下午考完了秋季的考试&#xff0c;最终得了97分&#xff0c;第一题扣了3分&#xff0c;非常遗憾。还有一个多小时的时候就已经97了&#xff0c;回来和第一题的剩余3分周旋到最后&#xff0c;没能发现问题所在&#xff0c;不停考虑各种&#xff0c;我觉得可能是…

1001. 害死人不偿命的(3n+1)猜想 (15)

卡拉兹(Callatz)猜想&#xff1a; 对任何一个自然数n&#xff0c;如果它是偶数&#xff0c;那么把它砍掉一半&#xff1b;如果它是奇数&#xff0c;那么把(3n1)砍掉一半。这样一直反复砍下去&#xff0c;最后一定在某一步得到n1。卡拉兹在1950年的世界数学家大会上公布了这个猜…

2019年12月PAT甲级满分备考经验

PAT甲级满分备考经验答题过程备考经验答题过程 总得来说&#xff0c;我觉得我幸运&#xff0c;碰上了一次PAT甲级题目相当简单&#xff08;1085中有190人满分&#xff09;&#xff0c;最终提前一小时交卷&#xff0c;实时排名为35。   我按照1 2 3 4顺序第一回写&#xff0c;因…

PAT 1022 Complete Binary Search Tree (30)

思路 1.a[n]可以用来装这棵树&#xff0c;a[0]到a[n-1]输出的话就可以看作是bfs输出&#xff0c;关键是要标记出a[0]到a[n-1]应该把第几个数&#xff08;已经排好序&#xff09;输出。2.叫记住&#xff0c;对于a[i],他的左节点是a[2*i1],右节点是a[2*i2]&#xff0c;并且只要其…

PAT 1145 Hashing - Average Search Time

个人学习记录&#xff0c;代码难免不尽人意。 The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average search time (the…

【PAT】攀拓(PAT)- 程序设计(甲级)2023年夏季考试自测

个人学习记录&#xff0c;代码难免不尽人意。 今天又斥资巨款买了PAT甲级2023年夏季的考试真题做了做&#xff0c;得分 95&#xff0c;还买了时光机&#xff0c;在当时排名42名。总的来说还是比较满意的&#xff01;有些地方当时做的时候卡住了但是后面回过头来重新想的时候还是…

PAT-Deduplication on a Linked List

题意&#xff1a;给你n条记录&#xff0c;每天记录由一下三部分组成&#xff08;地址&#xff0c;key&#xff0c;next_address&#xff09;&#xff0c;再给你一个起始地址。让你输出两个新的list&#xff0c;一个是将原来的list删除key的绝对值之后的list&#xff0c;一个是被…

PAT甲级真题 1043 Is It a Binary Search Tree (25分) C++实现(二叉搜索树,递归前序转后序)

题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node’s key. The right subtree of a node contains only nodes with keys grea…

PAT甲级真题 1088 Rational Arithmetic (20分) C++实现(有理数四则运算,简单模拟,注意测试点2、3)

题目 For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient. Input Specification: Each input file contains one test case, which gives in one line the two rational numbers…

一元多项式求导

设计函数求一元多项式的导数。 输入格式: 以指数递降方式输入多项式非零项系数和指数&#xff08;绝对值均为不超过 1000 的整数&#xff09;。数字间以空格分隔。 输出格式: 以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔&#xff0c;但结尾不能有…

PAT 1016. Phone Bills (25)(map排序,去掉不匹配的,分时计算money)(待修改)

题目 1016. Phone Bills (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amo…

PAT甲级真题 1056 Mice and Rice (25分) C++实现(数组模拟分组淘汰赛,map记录重量排名,题意分析)

题目 Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice as possible in order to become a FatMouse. First…

PAT甲级真题 1091 Acute Stroke (30分) C++实现(bfs累计节点数,dfs会栈溢出)

题目 One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core. Input …

PAT甲级真题 1093 Count PAT‘s (25分) C++实现(同PAT乙级真题 1040)

题目 The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters. Now given any string, you are supposed to tell the numb…

H264系列(3):CMMB中的H264和AAC打包成ts流

转自http://blog.csdn.net/zs_pro_popper/article/details/8179734参照tstools这个开源项目完成了CMMB的merge aac with 264 to TS.在做的过程中&#xff0c;分成了几个阶段。先试着将H264打包成TS,这花了最大的精力和时间&#xff1b;接着将AAC打包成TS&#xff1b;最后将其合…

PAT:A+B和C

题目描述 给定区间[-2的31次方, 2的31次方]内的3个整数A、B和C&#xff0c;请判断AB是否大于C。 输入描述: 输入第1行给出正整数T(<10)&#xff0c;是测试用例的个数。随后给出T组测试用例&#xff0c;每组占一行&#xff0c;顺序给出A、B和C。整数间以空格分隔。 输出描…

PAT:部分A+B

题目描述 正整数A的“DA&#xff08;为1位整数&#xff09;部分”定义为由A中所有DA组成的新整数PA。例如&#xff1a;给定A 3862767&#xff0c;DA 6&#xff0c;则A的“6部分”PA是66&#xff0c;因为A中有2个6。 现给定A、DA、B、DB&#xff0c;请编写程序计算PA PB。 …

牛客网-PAT乙级(Basic Level)真题-A+B和C (15)

相关说明&#xff1a; 时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 给定区间[-2的31次方, 2的31次方]内的3个整数A、B和C&#xff0c;请判断AB是否大于C。 输入描述: 输入第1行给出正整数T(<10)&#xff0c;是测试…

PAT甲级真题 1026 Table Tennis (30分) C++实现(窗口排队问题,细数多处坑)

题目 A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest number. If all the t…

PAT甲级真题 1061 Dating (20分) C++实现(同乙级1014,使用cctype)

题目 Sherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the coded time Thursda…

2019年12月PAT甲级 第一题 Good in C(1164)题解

题目 When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows? Input Specification: Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in …

PAT 1006. Sign In and Sign Out (25)(时间排序)

题目 1006. Sign In and Sign Out (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one w…

【PAT-1046】 Shortest Distance (20分)

考点&#xff1a;简单模拟 #include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std;int main(int argc, char const *argv[]) {int n;int m, sum 0;scanf("%d", &n);vector<int> r…

2021年3月份春季PAT甲级考试总结~~~

因为最近在准备考研&#xff0c;所以一直没机会来总结一下这次的PAT考试&#xff0c;今天抽个空来说说&#xff0c;算是为这几个月来的准备画上一个句号。 我大概算是从去年的十月份开始准备的&#xff0c;初衷是为了在大三的最后一段时间多参加一些比赛&#xff0c;避免考研进…

PAT A 1141 AC代码(测试点5可能的两种错误原因)

vector<node> Node(N)存储数据&#xff0c;用一个map记录了出现过的学校记录在Node的第几个 我是自己写的转换小写函数&#xff0c;用<cctype>中的tolower()更方便&#xff0c;我写的时候忘了 有个很有趣的问题&#xff0c;我一开始没有使用ans&#xff0c;直接对…

PAT 2019年冬 7-4 Cartesian Tree AC代码

根据题目描述&#xff0c;tree函数根据给出的中序和性质遍历树&#xff0c;然后每层记录在le[]中 #include<iostream> #include<vector> using namespace std; vector<int> in,le[30]; int N; void tree(int root,int start,int end,int level){if(start>…

PAT 2020年春 7-3 Safari Park AC代码

7-3 Safari Park (25 分) A safari park&#xff08;野生动物园&#xff09;has K species of animals, and is divided into N regions. The managers hope to spread the animals to all the regions, but not the same animals in the two neighboring regions. Of course,…

PAT 2020年秋 7-1 Panda and PP Milk (20 分) AC代码

7-1 Panda and PP Milk (20 分) PP milk &#xff08;盆盆奶&#xff09;is Pandas favorite. They would line up to enjoy it as show in the picture. On the other hand, they could drink in peace only if they believe that the amount of PP milk is fairly distribute…

PAT 1073 Scientific Notation

个人学习记录&#xff0c;代码难免不尽人意。 Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [][1-9].[0-9]E[][0-9] which means that the integer portion has exa…

PAT 1097 Deduplication on a Linked List

个人学习记录&#xff0c;代码难免不尽人意 Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or absolute value o…

L1006 连续因子

L1-006. 连续因子 时间限制 400 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 陈越一个正整数N的因子中可能存在若干连续的数字。例如630可以分解为3*5*6*7&#xff0c;其中5、6、7就是3个连续的数字。给定任一正整数N&#xff0c;要求编写程序求出最长连续因…

PAT甲级真题 1090 Highest Price in Supply Chain (25分) C++实现(dfs)

题目 A supply chain is a network of retailers&#xff08;零售商&#xff09;, distributors&#xff08;经销商&#xff09;, and suppliers&#xff08;供应商&#xff09;-- everyone involved in moving a product from supplier to customer. Starting from one root s…

L2-1 插松枝

L2-1 插松枝 分数 25 全屏浏览题目 切换布局 作者 陈越 单位 浙江大学 人造松枝加工场的工人需要将各种尺寸的塑料松针插到松枝干上&#xff0c;做成大大小小的松枝。他们的工作流程&#xff08;并不&#xff09;是这样的&#xff1a; 每人手边有一只小盒子&#xff0c;初始…

PAT乙级真题 1001 害死人不偿命的(3n+1)猜想 C++实现

题目 卡拉兹(Callatz)猜想&#xff1a; 对任何一个正整数 n&#xff0c;如果它是偶数&#xff0c;那么把它砍掉一半&#xff1b;如果它是奇数&#xff0c;那么把 (3n1) 砍掉一半。这样一直反复砍下去&#xff0c;最后一定在某一步得到 n1。卡拉兹在 1950 年的世界数学家大会上公…

.NET设计模式(10):装饰模式(Decorator Pattern)

原文地址为&#xff1a; .NET设计模式&#xff08;10&#xff09;&#xff1a;装饰模式&#xff08;Decorator Pattern&#xff09;装饰模式&#xff08;Decorator Pattern&#xff09; ——.NET设计模式系列之十 Terrylee&#xff0c;2006年3月 概述 在软件系统中&#xff0c;…

PAT甲级备考手册(附常见题型分类 C++实现)

常用函数 isPrime() #include <cmath> bool isPrime(int n){//用pow(n, 0.5)会超时&#xff0c;sqrt效率大增for (int i2; i<sqrt(n); i){if (n%i0){return false;}}return true; }isNumber() #include<sstream> bool isNumber(string s){istringstream sin(…

1082 Read Number in Chinese (25 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

本题稍难&#xff0c;如果没有思路&#xff0c;请顺序认真阅读本文&#xff01;&#xff08;全网最全最详细题目解析&#xff09; 1082 Read Number in Chinese&#xff08;20分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;…

1073 Scientific Notation (20 分) 全网最细 题目详解 翻译 完整代码 PAT甲级真题解析

1073 Scientific Notation &#xff08;20 分&#xff09;预备知识&#xff1a;题目翻译&#xff1a;输入格式&#xff1a;输出格式&#xff1a;题目解析&#xff1a;逻辑梳理&#xff1a;参考代码&#xff1a;预备知识&#xff1a; 本道题需要了解的预备知识&#xff1a;stri…

PAT 1046 Sharing (25)(不同长度字符串交点)

题目 1032. Sharing (25)时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the …

【PAT甲级 - C++题解】1078 Hashing

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4da;专栏地址&#xff1a;PAT题解集合 &#x1f4dd;原题地址&#xff1a;题目详情 - 1078 Hashing (pintia.cn) &#x1f511;中文翻译&#xff1a;哈希 &#x1f4e3;专栏定位&…

PAT:两个有序链表序列的合并

本题要求实现一个函数&#xff0c;将两个链表表示的递增整数序列合并为一个非递减的整数序列。 函数接口定义&#xff1a; List Merge( List L1, List L2 ); 其中List结构定义如下&#xff1a; typedef struct Node *PtrToNode; struct Node {ElementType Data; /* 存储结点数…

PAT A 2019年春 7-1 Sexy Primes AC代码

主要就是素数判断&#xff0c;注意一下往前判断的时候加一个>0的条件 #include<iostream> #include<cmath> using namespace std; int N; bool is_prime(int x){int k(int)sqrt(x*1.0);if(x0||x1) return false;for(int i2;i<k;i){if(x%i0) return false;}r…

pat:D进制的A+B

题目描述 输入两个非负10进制整数A和B(<2^30-1)&#xff0c;输出AB的D (1 < D < 10)进制数。 输入描述: 输入在一行中依次给出3个整数A、B和D。 输出描述: 输出AB的D进制数。 输入例子: 123 456 8 输出例子: 1103 #include <iostream> int main() {in…

1011 A+B 和 C (15 分)

给定区间 [−2​31​​,2​31​​] 内的 3 个整数 A、B 和 C&#xff0c;请判断 AB 是否大于 C。 输入格式&#xff1a; 输入第 1 行给出正整数 T (≤10)&#xff0c;是测试用例的个数。随后给出 T 组测试用例&#xff0c;每组占一行&#xff0c;顺序给出 A、B 和 C。整数间以…

PAT甲级真题 1081 Rational Sum (20分) C++实现(模拟分数加法)

题目 Given N rational numbers in the form “numerator/denominator”, you are supposed to calculate their sum. Input Specification: Each input file contains one test case. Each case starts with a positive integer N (<100), followed in the next line N …

PAT甲级真题 1082 Read Number in Chinese (25分) C++实现(中文读数,分治法)

题目 Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output “Fu” first if it is negative. For example, -123456789 is read as “Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu”. …

PAT甲级真题 1096 Consecutive Factors (20分) C++实现(不要被20分迷惑了,从2到sqrt(n)构造连乘因子)

题目 Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3567, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are supposed to find the maximum n…

【PAT刷题甲级】1031.Hello World for U

1031 Hello World for U (20 分) Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: h d e l l r lowoThat is, the characters must be printed in the original order, …

PAT备考之 贪心算法 专题

贪心主要有两种问题&#xff0c;分为简单贪心和区间贪心 1、简单贪心 比较好理解和思考&#xff1b;例如已有些单个数字怎样组合最大&#xff1b;出售固定量商品&#xff0c;怎样组合最赚钱。 2、区间贪心 &#xff08;1&#xff09;在一个大的区间内&#xff0c;尽量放入给出…

PAT A 1147 AC代码(堆,大顶堆小顶堆判断,后序遍历)

判断和后序遍历分别写成了两个单独函数。 按照堆的定义做即可。 #include<iostream> #include<vector> using namespace std; vector<int> heap,post; int M,N; bool Max,Min; void panduan(int index){if(index>N) return;if((2*index<N&&h…

PAT A 1145 AC代码(hash表及正向平方探查法)

注意一下正向平方探查法的部分 t(Keyj*j)%Msize 其中0<j<Msize #include<iostream> #include<cmath> using namespace std; bool is_prime(int x){if(x2) return true;int k(int)sqrt(x*1.0);for(int i2;i<k;i){if(x%i0) return false;}return true; }…

【PAT刷题甲级】1121.Damn Single

1121 Damn Single (25 分) “Damn Single (单身狗)” is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of. Input Specification Each input file contains one test c…

【PAT刷题甲级】1120.Friend Numbers

1120 Friend Numbers (20 分) Two integers are called “friend numbers” if they share the same sum of their digits, and the sum is their “friend ID”. For example, 123 and 51 are friend numbers since 123 51 6, and 6 is their friend ID. Given some number…

【PAT刷题甲级】1081.Rational Sum

1081 Rational Sum (20 分) Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum. Input Specification Each input file contains one test case. Each case starts with a positive integer N (≤100), followed in th…

PAT 1013. Battle Over Cities (25)(孤岛的个数,DFS或者BFS)

题目 1013. Battle Over Cities (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all th…

【PAT刷题甲级】1001.A+B Format

1001 AB Format (20 分) Calculate ab and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits). Input Specification Each input file contains one test case. Each …

C语言——PAT 乙级 【1005. 继续(3n+1)猜想】

题目&#xff1a; 卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里&#xff0c;情况稍微有些复杂。 当我们验证卡拉兹猜想的时候&#xff0c;为了避免重复计算&#xff0c;可以记录下递推过程中遇到的每一个数。例如对 n3 进行验证的时候&#xff0c;我们需要计算 …

C语言——PAT 乙级(1002.读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。)

题目&#xff1a; 读入一个正整数 n&#xff0c;计算其各位数字之和&#xff0c;用汉语拼音写出和的每一位数字。 输入格式&#xff1a; 每个测试输入包含 1 个测试用例&#xff0c;即给出自然数 n 的值。这里保证 n 小于 10​100​​。 输出格式&#xff1a; 在一行内输出…

Highest Price in Supply Chain (25)

A supply chain is a network of retailers&#xff08;零售商&#xff09;, distributors&#xff08;经销商&#xff09;, and suppliers&#xff08;供应商&#xff09;-- everyone involved in moving a product from supplier to customer. Starting from one root suppl…

Consecutive Factors (20)

题目描述 Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 356*7, where 5, 6, and 7 are the three consecutive numbers. Now given any positive N, you are supposed to find the maxi…

【PAT刷题甲级】1074.Reversing Linked List

1074 Reversing Linked List (25 分) 测试点1,5错误已解决。 Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K3, then you must output 3→2→1→6→5→…

【PAT甲级 - C++题解】1132 Cut Integer

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4da;专栏地址&#xff1a;PAT题解集合 &#x1f4dd;原题地址&#xff1a;题目详情 - 1132 Cut Integer (pintia.cn) &#x1f511;中文翻译&#xff1a;切整数 &#x1f4e3;专栏定位…

如何用cin获取带’/‘的分数

就是用一个char c去接收掉‘/’号即可&#xff1b; #include <iostream> using namespace std; struct Frac {int cld;int mth; }; int main() {Frac frac1, frac2;int k;char c;cin >> frac1.cld >>c>> frac1.mth >> frac2.cld >>c>&…

PAT-Acute Stroke

个人微信公众号&#xff1a; 题意&#xff1a;给定一个三维的数组&#xff0c;由0和1组成&#xff0c;如果一个联通分量中1的个数大于t&#xff0c;则该联通分量满足条件&#xff0c;问三维数组中满足条件的联通分量中的1 的个数。解法&#xff1a; dfs&#xff1a;利用递归来…

PAT甲级真题 1045 Favorite Color Stripe (30分) C++实现 (动态规划,最长不下降子序列(LIS))

题目 Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe. It i…

PAT甲级真题 1039 Course List for Student (25分) C++实现(map + set 存储,set能自动排序)

题目 Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query. Input Specification: Each input file c…

PAT甲级真题 1084 Broken Keyboard (20分) C++实现(简单遍历搜索)

题目 On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen. Now given a string that you are supposed to type, and the string that you actually type out, …

PAT 1008. Elevator (20)(简单加法)

题目 1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at wh…

[FFMPEG]MUXER:MPEGTS

代码文件&#xff1a;libavformat/mpegtsenc.c ##1.PAT/PMT插入间隔 1.1.插入间隔实质是根据ts->pat_period*90000.0) &#xff0c;sdt_packet_period和 force_pat共同决定的; static void retransmit_si_info(AVFormatContext *s, int force_pat, int64_t dts) {......i…

PAT甲级真题 1060 Are They Equal (25分) C++实现(模拟科学计数法)

题目 If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.12310​5with simple chopping. Now given the number of significant digits on a machine and two float numbers, you …

PTA题解 --- 剪切粘贴(C语言)

今天是PTA题库解法讲解的第五天&#xff0c;今天我们要讲解剪切粘贴&#xff0c;题目如下&#xff1a; 解题思路&#xff1a; 为了解决这个问题&#xff0c;你可以按照以下步骤进行&#xff1a; 读取输入字符串&#xff1a;首先读取原始字符串。 进行操作&#xff1a;根据输入…

L1011 A-B

L1-011. A-B 时间限制 100 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 陈越本题要求你计算A-B。不过麻烦的是&#xff0c;A和B都是字符串 —— 即从字符串A中把字符串B所包含的字符全删掉&#xff0c;剩下的字符组成的就是字符串A-B。 输入格式&#xff1a…

PTA题解 --- 静静的推荐(C语言)

今天是PTA题库解法讲解的第七天&#xff0c;今天我们要讲解静静的推荐&#xff0c;题目如下&#xff1a; 解题思路&#xff1a; 这个问题的核心在于如何在满足给定条件的情况下&#xff0c;最大化推荐学生的数量。首先&#xff0c;我们需要过滤出所有天梯赛成绩不低于175分的学…

PAT甲级题目分类(实时更新解题方法)

类型题号水题1136、1139、1143、1148字符串处理1001、1005、1035、1061、1073、1077、1082、1108、1140、1152模拟1002、1009、1017、1026、1042、1046、1065、1105查找元素1006、1011、1036动态规划1007、1040、1045、1068二分法1010、1044、1085双指针1029、1085、1089排序10…

A+B和C (15)

时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 给定区间[-2的31次方, 2的31次方]内的3个整数A、B和C&#xff0c;请判断AB是否大于C。 输入描述: 输入第1行给出正整数T(<10)&#xff0c;是测试用例的个数。随后给出T组…

【PAT刷题甲级】1042.Shuffling Machine

1042 Shuffling Machine (20 分) Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate with gamblers by performing inadeq…

【PAT刷题甲级】1136.A Delayed Palindrome

1136 A Delayed Palindrome (20 分) Consider a positive integer N written in standard notation with k1 digits ai as ak ⋯a1 a0 with 0≤ai <10 for all i and ak>0. Then N is palindromic if and only if ai ak−i for all i. Zero is written 0 and is also pa…

【PAT刷题甲级】1137.Final Grading

1137 Final Grading (25 分) 针对测试点3答案错误&#xff0c;已解决&#xff01; For a student taking the online course “Data Structures” on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no l…

【PAT甲级 - C++题解】1140 Look-and-say Sequence

✍个人博客&#xff1a;https://blog.csdn.net/Newin2020?spm1011.2415.3001.5343 &#x1f4da;专栏地址&#xff1a;PAT题解集合 &#x1f4dd;原题地址&#xff1a;题目详情 - 1140 Look-and-say Sequence (pintia.cn) &#x1f511;中文翻译&#xff1a;外观数列 &#x1…

PAT 1165 Block Reversing 思维量小的解法

个人学习记录&#xff0c;代码难免不尽人意。 Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K nodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to reverse all the…

PAT 1174 Left-View of Binary Tree 题干不知所云

个人学习记录&#xff0c;代码难免不尽人意。 The left-view of a binary tree is a list of nodes obtained by looking at the tree from left hand side and from top down. For example, given a tree shown by the figure, its left-view is { 1, 2, 3, 4, 5 } Given the…

pat乙级1002

关键思路&#xff1a; 大数输入问题 1010010100 用int和long long都是远远不够的&#xff0c;因此用字符数组来输入&#xff0c;然后再转换成整数 数字与拼音的转换 本题用最基本的方法&#xff0c;使用switch开关语句实现转换 拼音数字间有 1 空格&#xff0c;但一行中最后…

L2-2 老板的作息表

L2-2 老板的作息表 分数 25 全屏浏览题目 切换布局 作者 陈越 单位 浙江大学 新浪微博上有人发了某老板的作息时间表&#xff0c;表示其每天 4:30 就起床了。但立刻有眼尖的网友问&#xff1a;这时间表不完整啊&#xff0c;早上九点到下午一点干啥了&#xff1f; 本题就请你…

L1-095 分寝室PTA

学校新建了宿舍楼&#xff0c;共有 n 间寝室。等待分配的学生中&#xff0c;有女生 n0​ 位、男生 n1​ 位。所有待分配的学生都必须分到一间寝室。所有的寝室都要分出去&#xff0c;最后不能有寝室留空。 现请你写程序完成寝室的自动分配。分配规则如下&#xff1a; 男女生不能…

PAT B1024/A1073 科学计数法(纯字符串string操作)

本人计算机萌新&#xff0c;初学c将该题作为stl中的string各种操作的练习 写的较为繁琐&#xff0c;但起到了练习和理解string的操作的作用 #include #include using namespace std; int main() { int mark100000,z0,k,dotp,ep,cha; char p1,p2; string str,str2"."…

PAT 1164 Good in C 测试点3,4

个人学习记录&#xff0c;代码难免不尽人意。 When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows? Input Specification: Each input file contains one test case. For each case, the first part gives the 26 …

PAT-数据结构-例题

01-复杂度2 Maximum Subsequence Sum &#xff08;25 分&#xff09; Given a sequence of K integers { N​1​​, N​2​​, …, N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i1​​, …, N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence …