1004 Counting Leaves ——PAT甲级真题】的更多相关文章

1004 Counting Leaves A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each input file contains one test case. Each case starts with a line containing 0<N<10…
准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format  模拟输出,注意格式 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; string ans = ""; int main() { ; cin >> a >> b; c = a + b; ) {…
1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were 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. Eac…
正好这个"水水"的C4来了 先把甲级刷完吧.(开玩笑-2017.3.26) 这是一套"伪题解". wacao 刚才登出账号测试一下代码链接,原来是看不到..有空弄题(xia)解(che).. //"今天"的"收获": BST的中序遍历特性:栈那题利用树状数组+二分维护:哇咔咔,题意真难,根据案例猜题意.好吧,反正我又不考.不如睡觉? 出现了基础的二级最短路: 对DFS联通快愣了一下.. 哇塞呀!模拟题还是很劲的! 哇塞呀,手写…
2019/4/3 1063 Set Similarity n个序列分别先放进集合里去重.在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分子. // 1063 Set Similarity #include <set> #include <map> #include <cstdio> #include <iostream> #include <algorithm> using name…
1019. General Palindromic Number 题意:求数N在b进制下其序列是否为回文串,并输出其在b进制下的表示. 思路:模拟N在2进制下的表示求法,“除b倒取余”,之后判断是否回文. #include<iostream> #include<cstdio> using namespace std; ]; int main() { int n, b; scanf("%d%d", &n, &b); , tmp = n,yu=tmp…
题目概述:Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now…
题目分析: 由于本题字符串长度有10^5所以直接暴力是不可取的,猜测最后的算法应该是先预处理一下再走一层循环就能得到答案,所以本题的关键就在于这个预处理的过程,由于本题字符串匹配的内容的固定的PAT,所以我们可以这样想,对于一个输入的串,我们找到每个A的位置,只要知道这个A的前面有几个P,这个A的后面有几个T,就可以得到以这个A为中心的所有种数,二者相乘即可,然后如果我们能得到0~s.size()-1范围内每个A的前面有多少个P,每个A后面有多少个T,只要从头遍历一遍并且求和就能得到最终答案,由…
前言: 本题是我在浏览了柳神的代码后,记下的一次半转载式笔记,不经感叹柳神的强大orz,这里给出柳神的题解地址:https://blog.csdn.net/liuchuo/article/details/52316405 题意: 有一个租借自行车的系统由n个点组成,用户可以在这n个点任意一个点借车或者还车,每个点都遵循一个共同的上限c,这里我们称一个点的状态时完美的如果这个点的车的数量为c/2,(每个点由1~n标号),而我们的出发点为0点,整个系统每次会有一个sp点发出警报,说明这个sp点的自行…
1022 Digital Library 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 assigned an unique 7-digit number as its ID. Given any query fro…