7-3 Postfix Expression (25 分) Given a syntax tree (binary), you are supposed to output the corresponding postfix expression, with parentheses reflecting the precedences of the operators. Input Specification Each input file contains one test case. For…
Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebration, the alumni association (校友会) has gathered the ID’s of all her alumni. Now your job is to write a program to count the number of alumni among all…
7-4 Dijkstra Sequence (30 分) Dijkstra's algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from one particular source vertex to all the other vertices o…
7-2 Merging Linked Lists (25 分) Given two singly linked lists L 1 =a 1 →a 2 →...→a n−1 →a n  L1=a1→a2→...→an−1→an and L 2 =b 1 →b 2 →...→b m−1 →b m  L2=b1→b2→...→bm−1→bm . If n≥2m n≥2m , you are supposed to reverse and merge the shorter one into the…
7-1 Forever (20 分) "Forever number" is a positive integer A with K digits, satisfying the following constrains: the sum of all the digits of A is m; the sum of all the digits of A+1 is n; and the greatest common divisor of m and n is a prime num…
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, a binary tree can be uniquely determined. Now given a sequence of statements about the structure of the resulting tree, yo…
Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone c…
Sexy primes are pairs of primes of the form (p, p+6), so-named since “sex” is the Latin word for “six”. (Quoted from http://mathworld.wolfram.com/SexyPrimes.html) Now given an integer, you are supposed to tell if it is a sexy prime. Input Specificati…
A Good In C纯模拟题,用string数组读入数据,注意单词数量的判断 #include<bits/stdc++.h> using namespace std; ; ][]; int main () { ;i<=;i++) { ;j<=;j++) cin>>a[i][j]; } string t; getchar (); getline (cin,t); ]; ; ;i<t.length();i++) { if (t[i]>='A'&&…
给定一个链表,你需要删除那些绝对值相同的节点,对于每个绝对值K,仅保留第一个出现的节点.删除的节点会保留在另一条链表上.简单来说就是去重,去掉绝对值相同的那些.先输出删除后的链表,再输出删除了的链表. 建立结构体节点,包括起始地址addr,下一个地址to,值value.链表数组索引为地址,接下来就是模拟链表的操作了,并且建立一个flag数组标记对应值K是否出现,若出现则flag[k]=addr,未出现则为-1,注意这里不能为0因为地址值存在为0的情况.最后的输出地址前面要补0,如果是链尾的话,-…
1043 Is It a Binary Search Tree (25 分)   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…
1033 To Fill or Not to Fill (25 分)   With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may…
题意:输入一个正整数N(<=1e5),两个小数P和R,分别表示树的结点个数和商品原价以及每下探一层会涨幅的百分比.输出叶子结点深度最小的商品价格和深度最小的叶子结点个数. trick: 测试点1只有根节点一个点,输出P和1. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; vector<]; ]; void dfs(int x,int y){ )…
题意: 输入一个地址和一个正整数N(<=100000),接着输入N行每行包括一个五位数的地址和一个结点的值以及下一个结点的地址.输出除去具有相同绝对值的结点的链表以及被除去的链表(由被除去的结点组成的链表). AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],val[]; vector<pair<int,int> >ans,a…
题意: 输入一个正整数N(<=1e5),和两个小数r和f,表示树的结点总数和商品的原价以及每向下一层价格升高的幅度.下一行输入N个结点的父结点,-1表示为根节点.输出最深的叶子结点处购买商品的价格以及有几个深度最深的结点. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; vector<]; int mx; ]; void dfs(int x…
题意: 输入一个正整数N(<=1e5),表示共有N个结点,接着输入两个浮点数分别表示商品的进货价和每经过一层会增加的价格百分比.接着输入N行每行包括一个非负整数X,如果X为0则表明该结点为叶子结点接着输入一个整数表示该零售商进货的数量,X不为零则接着输入X个正整数表示它的下级经销商是哪些结点.输出所有零售商进货的总价.(结点从0~N-1,0为根节点即供应商) AAAAAccepted code: #include<bits/stdc++.h> using namespace std; ]…
题意: 输入一个正整数N(<=100000),接着输入N个正整数(0~N-1的排列).每次操作可以将0和另一个数的位置进行交换,输出最少操作次数使得排列为升序. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],b[]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(…
题意: 给出学生人数M,输入M组学生ID,到机房的时间,离开机房的时间.输出最早到机房的学生的ID,空格,最后离开机房的学生的ID.(M大小未给出,就用了1e5) AAAAAccepted code: #include<bits/stdc++.h> using namespace std; ]; ],time2[]; pair<],t2[]; int main(){ int n; cin>>n; ;i<=n;++i){ cin>>name[i]>>…
最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel Plan (30)-PAT甲级真题(Dijkstra + DFS,输出路径,边权) All Roads Lead to Rome (30)-PAT甲级真题-Dijkstra + DFS Online Map (30)-PAT甲级真题(Dijkstra + DFS) 最短路径扩展问题 要求数最短路径有多…
PAT甲级考前整理一:https://www.cnblogs.com/jlyg/p/7525244.html,主要讲了131题的易错题及坑点 PAT甲级考前整理二:https://www.cnblogs.com/jlyg/p/10364696.html,主要讲了考前注意以及一些常用算法. 1132题:用字符串接收会毕竟快,使用atoi函数转成数字,注意a*b会超出int32. #include<iostream> #include<cstdio> #include<set&g…
PAT甲级考前整理之一网址:https://www.cnblogs.com/jlyg/p/7525244.html,主要总结了前面131题的类型以及易错题及坑点. PAT甲级考前整理三网址:https://www.cnblogs.com/jlyg/p/10364727.html主要是讲132题开始的题目. 考前注意: 1.写函数(有返回值的函数)容易忘记返回值,可能本地运行没问题,但是提交了就会有问题. 2.不要把strlen()函数写到for.while的循环中,有时候会超时,最好是 int…
   转载请注明出处:https://www.cnblogs.com/jlyg/p/7525244.html 终于在考前,刷完PAT甲级131道题目,不容易!!!每天沉迷在刷题之中而不能超脱,也是一种境界.PAT甲级题目总的说卡题目的比较多,卡测试点的比较少,有些题目还会有题意混淆,这点就不吐槽了吧.静下心来耍这130道题,其实磨练的是一种态度与手感,养成的是一种习惯.热爱AC没有错!!(根据自己的刷题情况持续更新中,这次是第二遍刷了,发现换了新网站后,oj严格很多了,有些之前可以过的,现在已经…
2019 秋季 PAT 甲级 备考总结 在 2019/9/8 的 PAT 甲级考试中拿到了满分,考试题目的C++题解记录在这里,此处对备考过程和考试情况做一个总结.如果我的方法能帮助到碰巧点进来的有缘人那就更好了Orz 目录 一.备考内容 1.  <算法笔记>(←阅读内容目录在这里) 2. PAT 题库刷题 3. 题型总结 + 刷题笔记 (←笔记目录在这里) 二.考试情况 1. 考前准备 2. 考试过程 3. 对这次考试的总结(碎碎念,可忽略) 一.备考内容 1.  <算法笔记>…
时间轴: 2017年,数据结构加入了我的课程清单. 2018年12月,我从网易云课堂下载了数据结构的所有课程视频(学校里没有网,只能离线看),开始一刷.一刷只看了视频,基本没有做题,看到AVL树的时候已经懵了,后来不了了之. 2019年7月,我开始二刷数据结构.事实证明不写代码一刷是没有用的,到后面完全不记得以前看过.这次我跟着进度来,每个算法都造轮子,每道题都做.我开始上PAT平台刷题,DSA题集的数据结构部分刷完以后,就开始刷甲级题,觉得难度适中,决定参加PAT甲级考试. 2019年8月,我…
今天开个坑,分类整理PAT甲级题目(https://pintia.cn/problem-sets/994805342720868352/problems/type/7)中1051~1100部分.语言是modern C++. 为什么要整理呢,因为我2019年9月要考PAT甲级,虽然是第一次考,虽然只学了数据结构(https://mooc.study.163.com/course/1000033001?tid=2402970002#/info),但我要冲着高分(2019年9月8日更新:满分)去. 下…
一次考试经历 今天是"大雪",很冷. 来到隔壁的学校考试,记得上一次来河中医是两年前大一刚开学吧,那天晚上印象比较深刻,6个室友骑车到处闲逛.当时还不会Hello world. 很巧,遇到了一年前在网络上一起准备蓝桥杯的小伙伴,考前,相约明年再来考一次..然而,下次可能不会再来了. A题:字符串处理 B题:模拟链表 C题:图论,简单的邻接矩阵判断顶点相连 D题:小根堆,给出中序序列建树,输出层序遍历的序列. 除了第一题以外,其他三题都和往年的题型一样的. 第一题字符串看起来就比较难处理…
PAT链表专题 关于PAT甲级的链表问题,主要内容 就是"建立链表" 所以第一步学会模拟链表,pat又不卡时间,这里用vector + 结构体,更简洁 模拟链表的普遍代码 const int maxn = 1e6+10; struct node{ int address; int next; char key; }nod[maxn]; int head1,n; vector<node> list1; cin>>head1>>n; for(int i=…
周六PAT甲级考试复盘与总结 先说结论:仍未步入"高手"行列:现在的学习节奏与方法是对的,有十万分的必要坚持下去. 题目 知识点 分数 T1 前缀和.二分 11 / 20 T2 排序 25 / 25 T3 图论 17 / 25 T4 二叉树(根据中序遍历建树) 30 / 30 总分 // 83 / 100 题目很简单,总体来讲极其可惜: T1 和 T3 考试时实在没有找到 bug 出在哪里,目前 T1 的 bug 已经找到,我们先且复盘考试. 复盘 浙江大学计算机程序设计能力考试(Pr…
Visual Studio 2019 发布活动 2019 年 4 月 2 日,星期二 | 上午 9:00 (PT) 围观: https://visualstudio.microsoft.com/zh-hans/vs2019-launch/# https://github.com/Microsoft/VisualStudio2019Launch…
随着.NET Core的发布和开源,.NET又重新回到人们的视野..NET Core的下个3.0即将release,加入非常多的新功能,越来越拥抱变化,DevOps和Microservice的最佳实践已经在.NET Core落地,比如 Ocelot网关.Grpc+Consul 服务注册发现.Apworks CQRS实现.Xigadee 微服务工具库.脚手架. 西安.NET社区组织发起了此次“拥抱变化, 又见.NET”线下交流活动,邀请了三位资深.NET开发者作为分享讲师,他们将从架构.原理.语言…