PAT
文章平均质量分 57
dauntless1310
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Pat知识储备——使用邻接表表示的树,使用bfs和dfs
测试数据: 8 1 2 1 7 1 4 2 8 2 5 4 3 3 9 4 6 注意点: h存放父节点,h的下标表示父节点的值,e表示子结点的值,ne表示兄弟节点的下一个位置 #include <cstring> #include <iostream> #include <algorithm> #include <queue> using namespace std; const int N = 100010; int n; int h[N], e[原创 2021-07-24 16:07:36 · 281 阅读 · 0 评论 -
Pat1061 Dating
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 Thursday 14:04原创 2021-07-23 21:43:38 · 130 阅读 · 0 评论 -
Pat1071 Speech Patterns
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 can help to narrow down a speaker’s identity, which is useful when validating, for exampl原创 2021-07-23 21:27:29 · 120 阅读 · 0 评论 -
Pat1050 String Subtraction
Given two strings S1 and S2, S=S1−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 to do it fast. Input Specificat原创 2021-07-20 19:34:59 · 125 阅读 · 0 评论 -
Pat1036 Boys vs Girls
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, followe原创 2021-07-20 17:44:45 · 138 阅读 · 0 评论 -
Pat1035 Password
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原创 2021-07-20 17:35:11 · 102 阅读 · 0 评论 -
Pat1006 Sign In and Sign Out
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, you are supposed to find the ones who have unlocked and loc原创 2021-07-20 17:27:29 · 127 阅读 · 0 评论 -
Pat1005 Spell It Right
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 English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (≤10 100 原创 2021-07-20 17:20:28 · 129 阅读 · 0 评论 -
PAT知识储备——合并集合(并查集)
一共有 n 个数,编号是 1∼n,最开始每个数各自在一个集合中。 现在要进行 m 个操作,操作共有两种: M a b,将编号为 a 和 b 的两个数所在的集合合并,如果两个数已经在同一个集合中,则忽略这个操作; Q a b,询问编号为 a 和 b 的两个数是否在同一个集合中; 输入格式 第一行输入整数 n 和 m。 接下来 m 行,每行包含一个操作指令,指令为 M a b 或 Q a b 中的一种。 输出格式 对于每个询问指令 Q a b,都要输出一个结果,如果 a 和 b 在同一集合内,则输出 Yes,否原创 2021-07-20 17:03:25 · 255 阅读 · 0 评论 -
PAT知识储备——单链表
单链表练习题 实现一个单链表,链表初始为空,支持三种操作: 向链表头插入一个数; 删除第 k 个插入的数后面的数; 在第 k 个插入的数后插入一个数。 现在要对该链表进行 M 次操作,进行完所有操作后,从头到尾输出整个链表。 注意:题目中第 k 个插入的数并不是指当前链表的第 k 个数。例如操作过程中一共插入了 n 个数,则按照插入的时间顺序,这 n 个数依次为:第 1 个插入的数,第 2 个插入的数,…第 n 个插入的数。 输入格式 第一行包含整数 M,表示操作次数。 接下来 M 行,每行包含一个操作命令原创 2021-07-20 16:52:23 · 142 阅读 · 0 评论 -
Pat1001 A+B Format
计划想考个PAT,考虑到自己C++基本功不熟,就在这儿做一些笔记以方便我后面过来看看: 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). Input Specification: Each input file contains o原创 2021-07-12 23:25:05 · 272 阅读 · 2 评论 -
PAT basic 1001 害死人不偿命的(3n+1)猜想 (15 分)
卡拉兹(Callatz)猜想: 对任何一个正整数 n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把 (3n+1) 砍掉一半。这样一直反复砍下去,最后一定在某一步得到 n=1。卡拉兹在 1950 年的世界数学家大会上公布了这个猜想,传说当时耶鲁大学师生齐动员,拼命想证明这个貌似很傻很天真的命题,结果闹得学生们无心学业,一心只证 (3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意延缓美国数学界教学与科研的进展…… 我们今天的题目不是证明卡拉兹猜想,而是对给定的任一不超过 1000 的正整数 n,简单原创 2021-06-15 14:12:07 · 106 阅读 · 0 评论
分享