Skip to content

tiny656/PAT

Repository files navigation

📚PAT是浙江大学计算机程序设计能力测试系统, 被用于研究生机试和PAT证书资格测试

这个Project维护大部分题库的代码, 其中的一些也参考过一些blog版本

代码主要语言使用C++, C, Python, Java, Go

绝大多数代码中开头的注释写有简单的解题思路,希望对大家能有所帮助,有关研究生生活的信息,也欢迎咨询:smiley:

目录

Top-Level

ID Title Code
1001 Battle Over Cities - Hard Version (35) C++
1002 Business (35) C++
1003 Universal Travel Sites (35) C++
1004 To Buy or Not to Buy - Hard Version (35) C++
1005 Programming Pattern (35) C++
1006 Tree Traversals - Hard Version (35) Python
1007 Red-black Tree (35) C++
1008 Airline Routes (35) C++
1009 Triple Inversions (35) C++
1010 Lehmer Code (35) C++
1011 Cut Rectangles (35) Python
1012 Greedy Snake (35) C++
1013 Image Segmentation (35) Python
1014 Circles of Friends (35) C++
1015 Letter-moving Game (35) C++
1016 Uniqueness of MST (35) C++
1017 The Best Peak Shape (35) Python
1018 Subnumbers (35) Python
1019 Separate the Animals (35) C++
1020 Delete At Most Two Characters (35) C++
1021 Safe Fruit (35) C++
1022 Werewolf (35) C++
1023 The Best Polygon (35) C++
1024 Currency Exchange Centers (35) C++
1025 Keep at Most 100 Characters (35) C++
1026 String of Colorful Beads (35) C++
1027 Larry and Inversions (35) C++
1028 Do All Roads Lead to Rome (35) C++
1029 Array Cutting Score (35) C++
1030 Beautiful Subsequence (35) C++
1032 Fighting the Monsters (35) C++
1033 Strings of Red and Blue (35) C++

Advance-Level

ID Title Code
1001 A+B Format (20) C++
1002 A+B for Polynomials (25) C++
1003 Emergency (25) C++
1004 Counting Leaves (30) C++
1005 Spell It Right (20) C++
1006 Sign In and Sign Out (25) C++
1007 Maximum Subsequence Sum (25) C++
1008 Elevator (20) C++
1009 Product of Polynomials (25) C++
1010 Radix (25) C++
1011 World Cup Betting (20) C++
1012 The Best Rank (25) C++
1013 Battle Over Cities (25) C++
1014 Waiting in Line (30) C++
1015 Reversible Primes (20) C++
1016 Phone Bills (25) C++
1017 Queueing at Bank (25) C++
1018 Public Bike Management (30) C++
1019 General Palindromic Number (20) C++
1020 Tree Traversals (25) C++
1021 Deepest Root (25) C++
1022 Digital Library (30) C++
1023 Have Fun with Numbers (20) C++
1024 Palindromic Number (25) Java
1025 PAT Ranking (25) C++
1026 Table Tennis (30) C++
1027 Colors in Mars (20) C++
1028 List Sorting (25) C++
1029 Median (25) C++
1030 Travel Plan (30) C++
1031 Hello World for U (20) C++
1032 Sharing (25) C++
1033 To Fill or Not to Fill (25) C++
1034 Head of a Gang (30) C++
1035 Password (20) C++
1036 Boys vs Girls (25) C++
1037 Magic Coupon (25) C++
1038 Recover the Smallest Number (30) C++
1039 Course List for Student (25) C++
1040 Longest Symmetric String (25) C++
1041 Be Unique (20) C++
1042 Shuffling Machine (20) C++
1043 Is It a Binary Search Tree (25) C++
1044 Shopping in Mars (25) C++
1045 Favorite Color Stripe (30) C++
1046 Shortest Distance (20) C++
1047 Student List for Course (25) C++
1048 Find Coins (25) C++
1049 Counting Ones (30) C++
1050 String Subtraction (20) C++
1051 Pop Sequence (25) C++
1052 Linked List Sorting (25) C++
1053 Path of Equal Weight (30) C++
1054 The Dominant Color (20) C++
1055 The World's Richest (25) C++
1056 Mice and Rice (25) C++
1057 Stack (30) C++
1058 A+B in Hogwarts (20) C++
1059 Prime Factors (25) C++
1060 Are They Equal (25) C++
1061 Dating (20) C++
1062 Talent and Virtue (25) C++
1063 Set Similarity (25) C++
1064 Complete Binary Search Tree (30) C++
1065 A+B and C (64bit) (20) C++
1066 Root of AVL Tree (25) C++
1067 Sort with Swap(0,) (25) C++
1068 Find More Coins (30) C++
1069 The Black Hole of Numbers (20) C++
1070 Mooncake (25) C++
1071 Speech Patterns (25) C++
1072 Gas Station (30) C++
1073 Scientific Notation (20) C++
1074 Reversing Linked List (25) C++
1075 PAT Judge (25) C++
1076 Forwards on Weibo (30) C++
1077 Kuchiguse (20) C++
1078 Hashing (25) C++
1079 Total Sales of Supply Chain (25) C++
1080 Graduate Admission (30) C++
1081 Rational Sum (20) C++
1082 Read Number in Chinese (25) C++
1083 List Grades (25) C++
1084 Broken Keyboard (20) Python
1085 Perfect Sequence (25) C++
1086 Tree Traversals Again (25) C++
1087 All Roads Lead to Rome (30) C++
1088 Rational Arithmetic (20) C++
1089 Insert or Merge (25) C++
1090 Highest Price in Supply Chain (25) C++Python
1091 Acute Stroke (30) C++
1092 To Buy or Not to Buy (20) C++
1093 Count PAT's (25) C++
1094 The Largest Generation (25) C++
1095 Cars on Campus (30) C++
1096 Consecutive Factors (20) C++
1097 Deduplication on a Linked List (25) C++
1098 Insertion or Heap Sort (25) C++
1099 Build A Binary Search Tree (30) C++
1100 Mars Numbers (20) Python
1101 Quick Sort (25) C++
1102 Invert a Binary Tree (25) C++
1103 Integer Factorization (30) C++
1104 Sum of Number Segments (20) Python
1105 Spiral Matrix (25) C++
1106 Lowest Price in Supply Chain (25) C++
1107 Social Clusters (30) C++
1108 Find Average (20) C++
1109 Group Photo (25) C++
1110 Complete Binary Tree (25) C++
1111 Online Map (30) C++
1112 Stucked Keyboard (20) C++
1113 Integer Set Partition (25) C++
1114 Family Property (25) C++
1115 Counting Nodes in a BST (30) Python
1116 Come on! Let's C (20) Python
1117 Eddington Number(25) Python
1118 Birds in Forest (25) Python
1119 Pre- and Post-order Traversals (30) Python
1120 Friend Numbers (20) Python
1121 Damn Single (25) Python
1122 Hamiltonian Cycle (25) Python
1123 Is It a Complete AVL Tree (30) Python
1124 Raffle for Weibo Followers (20) Python
1125 Chain the Ropes (25) Python
1126 Eulerian Path (25) C++
1127 ZigZagging on a Tree (30) Python
1128 N Queens Puzzle (20) C++
1129 Recommendation System (25) C++
1130 Infix Expression (25) Python
1131 Subway Map (30) Python
1132 Cut Integer (20) Python
1133 Splitting A Linked List (25) C++
1134 Vertex Cover (25) Python
1135 Is It A Red-Black Tree (30) Python
1136 A Delayed Palindrome (20) Python
1137 Final Grading (25) C++
1138 Postorder Traversal (25) C++
1139 First Contact (30) C++
1140 Look-and-say Sequence (20) C++
1141 PAT Ranking of Institutions (25) C++
1142 Maximal Clique (25) C++
1143 Lowest Common Ancestor (30) C++
1144 The Missing Number (20) C++
1145 Hashing - Average Search Time (25) C++
1146 Topological Order (25) C++
1147 Heaps (30) C++
1148 Werewolf - Simple Version (20) C++
1149 Dangerous Goods Packaging (25) C++
1150 Travelling Salesman Problem (25) C++
1151 LCA in a Binary Tree (30) C++
1152 Google Recruitment (20) C++
1153 Decode Registration Card of PAT (25) C++
1154 Vertex Coloring (25) C++
1155 Heap Paths (30) C++
1156 Sexy Primes (20) Python
1157 Anniversary (25) Python
1158 Telefraud Detection (25) C++
1159 Structure of a Binary Tree (30) C++
1160 Forever (20) Python
1161 Merging Linked Lists (25) C++
1162 Postfix Expression (25) C++
1163 Dijkstra Sequence (30) C++
1164 Good in C (20) Python
1165 Block Reversing (25) C++
1166 Summit (25) C++
1167 Cartesian Tree (30) C++
1168 Prime Day (20) Python
1169 The Judger (25) C++
1170 Safari Park (25) C++
1171 Replacement Selection (30) C++
1172 Panda and PP Milk (20) Python
1173 How Many Ways to Buy a Piece of Land (25) C++
1174 Left-View of Binary Tree (25) C++
1175 Professional Ability Test (30) C++
1176 The Closest Fibonacci Number (25) Python
1177 Subsequence in Substring (25) C++
1178 File Path (25) C++Python
1179 Chemical Equation (30) C++

Basic-Level

ID Title Code
1001 害死人不偿命的(3n+1)猜想 (15) C++
1002 写出这个数 (20) C++
1003 我要通过!(20) C++
1004 成绩排名 (20) C++
1005 继续(3n+1)猜想 (25) C++
1006 换个格式输出整数 (15) C++
1007 素数对猜想 (20) C++
1008 数组元素循环右移问题 (20) C++
1009 说反话 (20) C++
1010 一元多项式求导 (25) C++
1011 A+B和C (15) C++
1012 数字分类 (20) C++
1013 数素数 (20) C++
1014 福尔摩斯的约会 (20) C++
1015 德才论 (25) C++
1016 部分A+B (15) C++
1017 A除以B (20) Java
1018 锤子剪刀布 (20) C++
1019 数字黑洞 (20) C++
1020 月饼 (25) C++
1021 个位数统计 (15) C++
1022 D进制的A+B (20) C++
1023 组个最小数 (20) C++
1024 科学计数法 (20) C++
1025 反转链表 (25) C++
1026 程序运行时间 (15) Python
1027 打印沙漏 (20) Python
1028 人口普查 (20) C++
1029 旧键盘 (20) Python
1030 完美数列 (25) C++
1031 查验身份证 (15) C++
1032 挖掘机技术哪家强 (20) C++
1033 旧键盘打字 (20) C++
1034 有理数四则运算 (20) C++
1035 插入与归并 (25) C++
1036 跟奥巴马一起编程(15) C++
1037 在霍格沃茨找零钱(20) C++
1038 统计同成绩学生(20) C++
1039 到底买不买(20) C++
1040 有几个PAT(25) C++
1041 考试座位号(15) C++
1042 字符统计(20) C++
1043 输出PATest(20) C++
1044 火星数字(20) C++
1045 快速排序(25) C++
1046 划拳(15) Python
1047 编程团体赛(20) Python
1048 数字加密(20) Python
1049 数列的片段和(20) Python
1050 螺旋矩阵(25) C++
1051 复数乘法(15) C++
1052 卖个萌 (20) C++
1053 住房空置率(20) C++
1054 求平均值(20) C++
1055 集体照(25) C++
1056 组合数的和(15) Python
1057 数零壹(20) Python
1058 选择题(20) Python
1059 C语言竞赛(20) Python
1060 爱丁顿数(25) Python
1061 判断题(15) Python
1062 最简分数(20) Python
1063 计算谱半径(20) Python
1064 朋友数(20) Python
1065 单身狗(25) Python
1066 图像过滤(15) Python
1067 试密码(20) Python
1068 万绿丛中一点红(20) C++
1069 微博转发抽奖(20) Python
1070 结绳(25) Python
1071 小赌怡情(15) Python
1072 开学寄语(20) Python
1073 多选题常见计分法(20) Python
1074 宇宙无敌加法器(20) Python
1075 链表元素分类(25) C++
1076 Wifi密码 (15) Python
1077 互评成绩计算 (20) Python
1078 字符串压缩与解压 (20) Python
1079 延迟的回文数 (20) Python
1080 MOOC期终成绩 (25) C++
1081 检查密码 (15) C++
1082 射击比赛 (20) C++
1083 是否存在相等的差 (20) C++
1084 外观数列 (20) C++
1085 PAT单位排行 (25) C++
1086 就不告诉你 (15) C++
1087 有多少不同的值 (20) C++
1088 三人行 (20) C++
1089 狼人杀-简单版 (20) C++
1090 危险品装箱 (25) C++
1091 N-自守数 (15) C++
1092 最好吃的月饼 (20) C++
1093 字符串A+B (20) C++
1094 谷歌的招聘 (20) C++
1095 解码PAT准考证 (25) C++
1096 大美数 (25) Python
1097 矩阵行平移 (20) Python
1098 岩洞施工 (20) Python
1099 性感素数 (20) Python
1100 校庆 (25) Python
1101 B是A的多少倍 (15) Python
1102 教超冠军卷 (20) Python
1103 缘分数 (20) Python
1104 天长地久 (20) Python
1105 链表合并 (25) C++
1106 2019数列 (15) Python
1107 老鼠爱大米 (20) Python
1108 String复读机 (20) Python
1109 擅长C (20) Python
1110 区块反转 (25) C++
1111 对称日 (15) Python
1112 超标区间 (20) Python
1113 钱串子的加法 (20) Python
1114 全素日 (20) Python
1115 裁判机 (25) C++
1116 多二了一点 (15) Python
1117 数字之王 (20) Python
1118 如需挪车请致电 (20) Python
1119 胖达与盆盆奶 (20) Python
1120 买地攻略 (25) C++
1121 祖传好运 (15) Python
1122 找奇葩 (20) Python
1123 舍入 (20) Python
1124 最近的斐波那契数 (20) Python
1125 子串与子列 (25) C++

中国大学MOOC-陈越、何钦铭-数据结构-起步能力自测题

ID Title Code
自测-1 打印沙漏 (20) Python
自测-2 素数对猜想 (20) Python
自测-3 数组元素循环右移问题 (20) Python
自测-4 Have Fun with Numbers (20) Python
自测-5 Shuffling Machine (20) Python

基础编程题目集

ID Title Code
6-1 简单输出整数 (10) C
6-2 多项式求值 (20) C
6-3 简单求和 (10) C
6-4 求自定类型元素的平均 (10) C
6-5 求自定类型元素的最大值 (10) C
6-6 求单链表结点的阶乘和 (15) C
6-7 统计某类完全平方数 (20) C
6-8 简单阶乘计算 (10) C
6-9 统计个位数字 (15) C
6-10 阶乘计算升级版 (20) C
6-11 求自定类型元素序列的中位数 (25) C
6-12 判断奇偶性 (10) C
6-13 折半查找 (15) C
7-1 厘米换算英尺英寸 (15) Python
7-2 然后是几点 (15) Python
7-3 逆序的三位数 (10) Python
7-4 BCD解密 (10) Python
7-5 表格输出 (5) Python
7-6 混合类型数据格式化输入 (5) Python
7-7 12-24小时制 (15) Python
7-8 超速判断 (10) Python
7-9 用天平找小球 (10) Python
7-10 计算工资 (15) Python
7-11 分段计算居民水费 (10) Python
7-12 两个数的简单计算器 (10) Python
7-13 日K蜡烛图 (15) Python
7-14 求整数段和 (15) Python
7-15 计算圆周率 (15) Python
7-16 求符合给定条件的整数集 (15) Python
7-17 爬动的蠕虫 (15) Python
7-18 二分法求多项式单根 (20) Python
7-19 支票面额 (15) Python
7-20 打印九九口诀表 (15) Python
7-21 求特殊方程的正整数解 (15) Python
7-22 龟兔赛跑 (20) Python
7-23 币值转换 (20) Python
7-24 约分最简分式 (15) Python
7-25 念数字 (15) Python
7-26 单词长度 (15) Python
7-27 冒泡法排序 (20) Python
7-28 猴子选大王 (20) Python
7-29 删除字符串中的子串 (20) Python
7-30 字符串的冒泡排序 (20) Python
7-31 字符串循环左移 (20) Python
7-32 说反话-加强版 (20) Python
7-33 有理数加法 (15) Python
7-34 通讯录的录入与显示 (10) Python
7-35 有理数均值 (20) Python
7-36 复数四则运算 (15) Python
7-37 整数分解为若干项之和 (20) Python
7-38 数列求和-加强版 (20) Python

数据结构与算法题目集(中文)

ID Title Code
6-1 单链表逆转 (20) C
6-2 顺序表操作集 (20) C
6-3 求链式表的表长 (10) C
6-4 链式表的按序号查找 (10) C
6-5 链式表操作集 (20) C
6-6 带头结点的链式表操作集 (20) C
6-7 在一个数组中实现两个堆栈 (20) C
6-8 求二叉树高度 (20) C
6-9 二叉树的遍历 (25) C
6-10 二分查找 (20) C
6-11 先序输出叶结点 (15) C
6-12 二叉搜索树的操作集 (30) C
7-1 最大子列和问题 (20) Python
7-2 一元多项式的乘法与加法运算 (20) Python
7-3 树的同构 (25) Python
7-4 是否同一棵二叉搜索树 (25) Python
7-5 堆中的路径 (25) Python
7-6 列出连通集 (25) Python
7-7 六度空间 (30) C++
7-8 哈利·波特的考试 (25) C++
7-9 旅游规划 (25) C++
7-10 公路村村通 (30) C++
7-11 关键活动 (30) C++
7-12 排序 (25) C++
7-13 统计工龄 (20) Python
7-14 电话聊天狂人 (25) C++
7-16 一元多项式求导 (20) C++
7-17 汉诺塔的非递归实现 (25) C++
7-18 银行业务队列简单模拟 (25) C++
7-19 求链式线性表的倒数第K项 (20) C++
7-21 求前缀表达式的值 (25) Python
7-22 堆栈模拟队列 (25) C++
7-23 还原二叉树 (25) Python
7-24 树种统计 (25) C++
7-25 朋友圈 (25) C++
7-26 Windows消息队列 (25) C++
7-28 搜索树判断 (25) C++
7-29 修理牧场 (25) C++
7-30 目录树 (30) C++
7-31 笛卡尔树 (25) C++
7-32 哥尼斯堡的“七桥问题” (25) C++
7-33 地下迷宫探索 (30) C++
7-34 任务调度的合理性 (25) C++
7-35 城市间紧急救援 (25) C++
7-36 社交网络图中结点的“重要性”计算 (30) C++
7-37 模拟EXCEL排序 (25) C++
7-38 寻找大富翁 (25) C++
7-39 魔法优惠券 (25) C++
7-40 奥运排行榜 (25) C++
7-41 PAT排名汇总 (25) C++
7-42 整型关键字的散列映射 (25) C++
7-43 字符串关键字的散列映射 (25) C++
7-44 基于词频的文件相似度 (30) Python
7-45 航空公司VIP客户查询 (25) C++
7-46 新浪微博热门话题 (30) C++
7-47 打印选课学生名单 (25) C++
7-48 银行排队问题之单窗口“夹塞”版 (30) C++
7-49 打印学生选课清单 (25) C++
7-50 畅通工程之局部最小花费问题 (35) C++
7-51 两个有序链表序列的合并 (20) C++
7-52 两个有序链表序列的交集 (25) C++
7-53 两个有序序列的中位数 (25) C++

Data Structures and Algorithms (English)

ID Title Code
6-1 Deque (25) C
6-2 Two Stacks In One Array (20) C
6-3 Add Two Polynomials (20) C
6-4 Reverse Linked List (20) C
6-7 Isomorphic (20) C
6-8 Percolate Up and Down (20) C
6-9 Sort Three Distinct Keys (20) C
6-14 Count Connected Components (20) C

团体程序设计天梯赛-练习集

ID Title Code
L1-001 Hello World PythonGo
L1-002 打印沙漏 Python
L1-003 个位数统计 Python
L1-004 计算摄氏温度 PythonGo
L1-005 考试座位号 Python
L1-006 连续因子 Python
L1-007 念数字 Python
L1-008 求整数段和 Python
L1-009 N个数求和 Python
L1-010 比较大小 Python
L1-011 A-B Python
L1-012 计算指数 Python
L1-013 计算阶乘和 Python
L1-014 简单题 Python
L1-015 跟奥巴马一起画方块 Python
L1-016 查验身份证 Python
L1-017 到底有多二 Python
L1-018 大笨钟 Python
L1-019 谁先倒 Python
L1-020 帅到没朋友 Python
L1-021 重要的话说三遍 Python
L1-022 奇偶分家 Python
L1-023 输出GPLT Python
L1-024 后天 Python
L1-025 正整数A+B Python
L1-026 I Love GPLT Python
L1-027 出租 Python
L1-028 判断素数 Python
L1-029 是不是太胖了 Python
L1-030 一帮一 Python
L1-031 到底是不是太胖了 Python
L1-032 Left-pad Python
L1-033 出生年 Python
L1-034 点赞 Python
L1-035 情人节 Python
L1-036 A乘以B Python
L1-037 A除以B Python
L1-038 新世界 Python
L1-039 古风排版 Python
L1-040 最佳情侣身高差 Python
L1-041 寻找250 Python
L1-042 日期格式化 Python
L1-043 阅览室 Python
L1-044 稳赢 Python
L1-045 宇宙无敌大招呼 Python
L1-046 整除光棍 Python
L1-047 装睡 Python
L1-048 矩阵A乘以B Python
L1-049 天梯赛座位分配 Python
L1-050 倒数第N个字符串 Python
L1-051 打折 Python
L1-052 2018我们要赢 Python
L1-053 电子汪 Python
L1-054 福到了 Python
L1-055 谁是赢家 Python
L1-056 猜数字 Python
L1-057 PTA使我精神焕发 Python
L1-058 6翻了 Python
L1-059 敲笨钟 Python
L1-060 心理阴影面积 Python
L1-061 新胖子公式 Python
L1-062 幸运彩票 Python
L1-063 吃鱼还是吃肉 Python
L1-064 估值一亿的AI核心代码 Python
L1-065 嫑废话上代码 Python
L1-066 猫是液体 Python
L1-067 洛希极限 Python
L1-068 调和平均 Python
L1-069 胎压监测 Python
L1-070 吃火锅 Python
L1-071 前世档案 Python
L1-072 刮刮彩票 Python
L1-073 人与神 Python
L1-074 两小时学完C语言 Python
L1-075 强迫症 Python
L1-076 降价提醒机器人 Python
L1-077 大笨钟的心情 Python
L1-078 吉老师的回归 Python
L1-079 天梯赛的善良 Python
L1-080 乘法口诀数列 Python
L1-081 今天我要赢 Python
L1-082 种钻石 Python
L1-083 谁能进图书馆 Python
L1-084 拯救外星人 Python
L1-085 试试手气 Python
L1-086 斯德哥尔摩火车上的题 Python
L1-087 机工士姆斯塔迪奥 Python
L1-088 静静的推荐 Python
L1-089 最好的文档 Go
L1-090 什么是机器学习 Python
L1-091 程序员买包子 Python
L1-092 进化论 Python
L1-093 猜帽子游戏 Python
L1-094 剪切粘贴 Python
L1-095 分寝室 Python
L1-096 谁管谁叫爹 Python
L2-001 紧急救援 C++
L2-002 链表去重 C++
L2-003 月饼 C++
L2-004 这是二叉搜索树吗? C++
L2-005 集合相似度 C++
L2-006 树的遍历 C++
L2-007 家庭房产 C++
L2-008 最长对称子串 C
L2-009 抢红包 C++
L2-010 排座位 C++
L2-011 玩转二叉树 C++
L2-012 关于堆的判断 C++
L2-013 红色警报 C++
L2-014 列车调度 C++Go
L2-015 互评成绩 C++
L2-016 愿天下有情人都是失散多年的兄妹 C++
L2-017 人以群分 C++
L2-018 多项式A除以B C++
L2-019 悄悄关注 C++
L2-020 功夫传人 C++
L2-021 点赞狂魔 C++
L2-022 重排链表 C++
L2-023 图着色问题 C++
L2-024 部落 C++
L2-025 分而治之 C++
L2-026 小字辈 C++
L2-027 名人堂与代金券 C++
L2-028 秀恩爱分得快 C++
L2-029 特立独行的幸福 C++
L2-033 简单计算器 C++
L2-035 完全二叉树的层序遍历 C++