甲级
文章平均质量分 60
weixin_43820008
这个作者很懒,什么都没留下…
展开
-
PAT(甲级)2020年冬季考试 7-1 The Closest Fibonacci Number (20 分)
题目The Fibonacci sequence FnF_nFn is defined by Fn+2=Fn+1+FnF_{n+2}=F_{n+1}+F_{n}Fn+2=Fn+1+Fn for n≥0, with F0=0F_{0}=0F0=0and F1=1F_{1}=1F1=1. The closest Fibonacci number is defined as the Fibonacci number with the smallest absolute differen原创 2021-03-10 15:18:52 · 107 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1125 Chain the Ropes (25 分)
思路每两条绳子折叠并为一条绳子的时候,长度折半,为了得到最长的绳子,需要先从小到大排序,由最短的向最长的折叠。代码#include<iostream>#include<algorithm>using namespace std;int main(){ int n; scanf("%d",&n); double a[n]; for(int i = 0;i < n;i++) scanf("%lf",&a[i]); sort(a,a+n);原创 2021-03-09 16:23:52 · 66 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1121 Damn Single (25 分) 测试点
吐槽点第一次6分,第二次25分,只差了一行代码#include<iostream>#include<vector>#include<algorithm>using namespace std;struct Node{ int cp = -1; bool yq = false;};int main(){ int n; scanf("%d",&n); Node node[100000]; for(int i = 1;i <= n;i原创 2021-03-09 15:05:14 · 182 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1041 Be Unique (20 分)
题目Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10410^4104 ]. The first one who bets on a unique number wins. For example, if there原创 2021-03-07 20:46:14 · 110 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1046 Shortest Distance (20 分)
题目The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains one test case. For each case, the first line contai原创 2021-03-07 13:04:28 · 76 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1048 Find Coins (25 分)
题目Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment: for原创 2021-03-07 11:37:37 · 112 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1050 String Subtraction (20 分)
代码#include<iostream>using namespace std;int main(){ string s1,s2; getline(cin,s1); getline(cin,s2); int a[300]; fill(a,a+300,1); for(int i = 0;i < s2.length();i++) { a[s2[i]] = 0; } for(int i = 0;i < s1.length();i++) { if(a[s1原创 2021-03-07 10:34:57 · 69 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1051 Pop Sequence (25 分)
题目Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obt原创 2021-03-06 23:03:12 · 139 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1052 Linked List Sorting (25 分)
题目A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are supposed to sort the structu原创 2021-03-06 22:25:59 · 87 阅读 · 0 评论 -
PAT (Advanced Level) Practice 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=p1k1×p2k2×⋅⋅⋅×pmkmN=p_1^{k_1}\times p_2^{k_2}\times ···\times p_m^{k_m}N=p1k1×p2k2×⋅⋅⋅×pmkm吐槽点一开始是测试点3通过不了,看网上说是“1=1”没有,但是我当时是有的,具体如代原创 2021-03-06 10:26:56 · 116 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1064 Complete Binary Search Tree (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 the node’s key.The right subtree of a node contains only nodes with keys greater原创 2021-03-04 11:43:46 · 144 阅读 · 1 评论 -
PAT (Advanced Level) Practice 1080 Graduate Admission (30 分)
题目It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.Each applicant will have to provide two g原创 2021-03-02 14:26:10 · 89 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1083 List Grades (25 分)
题目Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.Input Specification:Each in原创 2021-03-02 13:05:50 · 128 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1093 Count PAT‘s (25 分)
题目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 number原创 2021-03-01 14:03:38 · 71 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1040 Longest Symmetric String (25 分)
题目Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.Input Specification:Each input file原创 2021-02-28 11:11:31 · 98 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1029 Median (25 分)
题目Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences is defined to be the原创 2021-02-23 21:17:31 · 90 阅读 · 0 评论 -
PAT (Advanced Level) Practice 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 (≤10510^{5}105 ) and C, where N is the nu原创 2021-02-23 20:59:22 · 62 阅读 · 0 评论 -
PAT甲级技巧点
PAT日记1.如果有多个需要排序bool cmp1(s s1,s s2){ return s1.score == s2.score ? s1.id < s2.id : s1.score > s2.score;}原创 2021-02-23 20:08:23 · 86 阅读 · 0 评论 -
PAT (Advanced Level) Practice 1024 Palindromic Number (25 分)
1024 Palindromic Number (25 分)题目A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Non-palindromic numb原创 2021-02-23 15:49:30 · 67 阅读 · 0 评论