![](https://img-blog.csdnimg.cn/2020012212495715.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
PAT甲级
PAT刷题总结,经验总结。利用C/C++求解问题,编译器采用g++
灯灯登登
杂学派,热衷各种技术
展开
-
C++中常用的字符处理函数
使用内置函数提升刷题效率C++中常用的几个字符处理函数islower(char c) 是否为小写字母isuppper(char c) 是否为大写字母isdigit(char c) 是否为数字isalpha(char c) 是否为字母isalnum(char c) 是否为字母或者数字toupper(char c) 字母小转大tolower(char c) 字母大转小大小写转换统一转成大写:ch & 0b11011111 简写:ch & 0xDF统一转成小写:ch |原创 2020-06-05 17:07:29 · 208 阅读 · 0 评论 -
PAT 甲级 A1045
题目连接1045 Favorite Color Stripe (30分)题目大意给定一个Eva喜欢的颜色序列和一个总的颜色序列,从总的颜色序列中找出按Eva喜欢的颜色序列顺序出现的最长子序列。有点绕,结合样例来说明什么意思。假设Eva喜欢的颜色序列为 {2 3 1 5 6},总的颜色序列为{2 2 4 1 5 5 6 3 1 1 5 6}.那么需要从总的颜色序列中找出符合题意的序列有 {2 ...原创 2020-04-14 18:47:33 · 179 阅读 · 0 评论 -
cin和cout提速
在主函数main开头加入一下两句,可以让cin和cout速度大幅度增加:#include <iostream>int main() { ios::sync_with_stdio(false); cout.tie(NULL); return 0;}直观感受一下加了这两句对C++读入的性能提升(貌似比用scanf还快):速度提升了近2倍多,其原理是,C/C++有各自...原创 2020-04-13 19:25:51 · 1340 阅读 · 0 评论 -
PAT 甲级 A1017
题目连接Queueing at Bank (25分)题目大意给定N个顾客,K个服务窗口一系列的用户到达时间,需要服务的时间。最后需要输出平均等待时间。注意,只考虑在银行营业期间到来的顾客。思路由于给的时间数据(hh:mm:ss)有点麻烦,为了方便计算需要先转化为最小的时间粒度单位,比如秒。时间统一转化函数如下:int convertTime(int h, int m, int s) {...原创 2020-03-31 20:37:18 · 219 阅读 · 0 评论 -
PAT 甲级 A1030
题目连接1030 Travel Plan (30分)题目大意给定输入输出格式,输出源结点到目标结点的最短路径、距离、cost。若最短路径有多条,则输出cost之和最少的那条思路在原来邻接表的基础上,增多一个cost表示花费,并且设置vector<int>pre[maxn]来表示结点最短路径的前驱(因为从源节点到目标结点的最短路径可能有多条,因此pre[i]表示的是结点i所有最...原创 2020-03-26 17:54:56 · 152 阅读 · 0 评论 -
PAT 甲级 A1086
1086 Tree Traversals Again (25分)题目描述An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys number...原创 2020-02-20 15:47:35 · 222 阅读 · 0 评论 -
PAT 甲级 A1103
1103 Integer Factorization (30分)题目描述The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K...原创 2020-02-19 21:53:12 · 121 阅读 · 0 评论 -
PAT 甲级 A1097
1097 Deduplication on a Linked List (25分)题目描述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...原创 2020-02-16 15:38:53 · 197 阅读 · 0 评论 -
PAT 甲级 A1074
1074 Reversing Linked List (25分)题目描述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 K=3, the...原创 2020-02-16 13:21:20 · 260 阅读 · 1 评论 -
PAT 甲级 A1056
1056 Mice and Rice (25分)题目描述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 eac...原创 2020-02-15 19:27:51 · 224 阅读 · 0 评论 -
PAT 甲级 A1001
1001 A+B Format (20分)题目描述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 less than four digits).输入格式Eac...原创 2020-02-15 13:27:55 · 106 阅读 · 0 评论 -
PAT 甲级 A1051
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...原创 2020-02-15 13:12:03 · 143 阅读 · 0 评论 -
PAT 甲级 A1052
1022 Digital Library (30分)题目描述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...原创 2020-02-14 17:35:24 · 202 阅读 · 0 评论 -
PAT 甲级 A1032
1032 Sharing (25分)题目描述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 same sublist if they share the s...原创 2020-02-14 15:13:35 · 159 阅读 · 0 评论 -
PAT 甲级 A1022
1022 Digital Library (30分)题目描述A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is ass...原创 2020-02-13 15:18:53 · 175 阅读 · 0 评论 -
PAT 甲级 A1054
1071 Speech Patterns (25分)题目描述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 p...原创 2020-02-13 13:18:36 · 221 阅读 · 0 评论 -
PAT 甲级 A1071
1071 Speech Patterns (25分)题目描述People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns c...原创 2020-02-12 14:04:24 · 121 阅读 · 0 评论 -
PAT 甲级 A1100
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, s...原创 2020-02-12 12:39:20 · 125 阅读 · 0 评论 -
PAT 甲级 A1060
1060 Are They Equal (25分)题目描述Each input file contains one test case which gives three numbers N, A and B, where N (<100) is the number of significant digits, and A and B are the two float numbers...原创 2020-02-12 09:56:18 · 103 阅读 · 0 评论 -
PAT 甲级 A1039
1039 Course List for Student (25分)题目描述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...原创 2020-02-11 11:41:28 · 131 阅读 · 0 评论 -
PAT 甲级 A1104
1104 Sum of Number Segments (20分)题目描述Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 se...原创 2020-02-08 14:20:52 · 153 阅读 · 0 评论 -
PAT 甲级 A1010
1010 1010 Radix (25分)题目描述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 number and 110 is a binary number.Now for...原创 2020-02-05 17:53:02 · 177 阅读 · 0 评论 -
PAT 甲级 A1084
1084 Broken Keyboard (20分)题目描述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 ...原创 2020-01-23 23:06:40 · 136 阅读 · 0 评论 -
PAT 甲级 A1025
1012 The Best Rank (25分)题目描述To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus o...原创 2020-01-22 12:40:42 · 151 阅读 · 1 评论