John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him gene…
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners…
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him gene…
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him gene…
Source: PAT A1124 Raffle for Weibo Followers (20 分) Description: John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his…
PAT甲级:1124 Raffle for Weibo Followers (20分) 题干 John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give aw…
1124 Raffle for Weibo Followers (20 分)   John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gif…
1124 Raffle for Weibo Followers(20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts.…
1124 Raffle for Weibo Followers (20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts…
1124. Raffle for Weibo Followers (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners…
1124 Raffle for Weibo Followers(20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts.…
PAT甲级1076. Forwards on Weibo 题意: 微博被称为中文版的Twitter.微博上的一位用户可能会有很多关注者,也可能会跟随许多其他用户.因此,社会网络与追随者的关系形成.当用户在微博上发布帖子时,他/她的所有跟随者可以查看和转发他/她的帖子,然后可以由他们的追随者再次转发. 现在给出一个社交网络,假定只计算间接跟随者的L个级别,您应该计算任何特定用户的最大潜在潜在金额. 输入规格: 每个输入文件包含一个测试用例.对于每种情况,第一行包含2个正整数:N(<= 1000),…
1076 Forwards on Weibo (30分)   Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post o…
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post on Weibo, all his/her followers…
题意:水题,直接贴代码了.(为什么我第一遍做的时候代码写的那么烦?) 代码: #include <iostream> #include <string> #include <vector> #include <map> #include <fstream> using namespace std; int main() { //ifstream cin("pat.txt"); int forwardCnt,step,start…
树(23) 备注 1004 Counting Leaves   1020 Tree Traversals   1043 Is It a Binary Search Tree 判断BST,BST的性质 1053 Path of Equal Weight   1064 Complete Binary Search Tree 完全二叉树的顺序存储,BST的性质 1066 Root of AVL Tree 构建AVL树,模板题,需理解记忆 1079 Total Sales of Supply Chain…
1121 Damn Single 模拟 // 1121 Damn Single #include <map> #include <vector> #include <cstdio> #include <iostream> #include <algorithm> using namespace std; map<int, int> m, vis; vector<int> p; ; int a[N]; int main()…
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~~ 时隔两年,又开始刷题啦,这篇用于PAT甲级题解,会随着不断刷题持续更新中,至于更新速度呢,嘿嘿,无法估计,不知道什么时候刷完这100多道题. 带*的是我认为比较不错的题目,其它的难点也顶多是细节处理的问题~ 做着做着,发现有些题目真的是太水了,都不想写题解了…
最短路径 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甲级分类汇编系列文章. 图,就是层序遍历和Dijkstra这一套,#include<queue> 是必须的. 题号 标题 分数 大意 时间 1072 Gas Station 30 最短距离最大,距离不超限 200ms 1076 Forwards on Weibo 30 一定层数的转发计数 3000ms 1079 Total Sales of Supply Chain 25 计算供应链总销售额 250ms 1087 All Roads Lead to Rome 30 复杂权重的最短路…
今天开个坑,分类整理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日更新:满分)去. 下…
PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任务是找到他/她目的地的最快方式. 输入规格: 每个输入文件包含一个测试用例.对于每种情况,第一行包含正整数N(<= 100),地铁线数.然后N行跟随,第i(i = 1,...,N)行以格式描述第i条地铁线: M S [1] S [2] ... S [M] 其中M(<= 100)是停止次数,S [i…
PAT甲级1127. ZigZagging on a Tree 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按顺序打印数字.但是,如果您认为问题太简单,那么您太天真了. 这次你应该以"锯齿形顺序"打印数字 - 也就是说,从根开始,逐级打印数字,从左到右交替,从右到左.例如,对于以下树,您必须输出:1 11 5 8 17 12 20 15. 输入规格: 每个输入文件包含一个测试用例.对于每种情况,第…
PAT甲级1123. Is It a Complete AVL Tree 题意: 在AVL树中,任何节点的两个子树的高度最多有一个;如果在任何时候它们不同于一个,则重新平衡来恢复此属性.图1-4说明了旋转规则. 现在给出一系列插入, 您应该输出生成的AVL树的级别遍历序列,并告知它是否是完整的二叉树. 输入规格: 每个输入文件包含一个测试用例.对于每种情况,第一行包含正整数N(<= 20). 一行中的所有数字都以空格分隔. 输出规格: 对于每个测试用例,将键逐个插入到初始空的AVL树中.然后首先…
PAT甲级1119. Pre- and Post-order Traversals 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二进制树可以通过给定的一对后序和顺序遍历序列来确定,也可以通过预序和顺序遍历序列来确定.然而,如果仅给出了后序和预序遍历序列,则相应的树可能不再是唯一的. 现在给出一对postorder和preorder遍历序列,你应该输出树的相应的顺序遍历序列.如果树不是唯一的,只需输出任何一个树. 输入规格: 每个输入文件包含一个测试用例.对于每种情况,第一行给出正整数…
PAT甲级1114. Family Property 题意: 这一次,你应该帮我们收集家族财产的数据.鉴于每个人的家庭成员和他/她自己的名字的房地产(房产)信息,我们需要知道每个家庭的规模,以及他们的房地产的平均面积和数量. 输入规格: 每个输入文件包含一个测试用例.对于每种情况, 第一行给出正整数N(<= 1000).然后N行跟随,每个给出一个拥有庄园的人的信息,格式如下: ID父亲母亲k Child1 ... Childk M_estate Area 其中ID是每个人唯一的4位数识别号码;父…
PAT甲级1111. Online Map 题意: 输入我们当前的位置和目的地,一个在线地图可以推荐几条路径.现在你的工作是向你的用户推荐两条路径:一条是最短的,另一条是最快的.确保任何请求存在路径. 输入规格: 每个输入文件包含一个测试用例.对于每种情况, 第一行给出两个正整数N(2 <= N <= 500),M分别是地图上街道交叉路口的总数和街道数.然后M行跟随,每个描述一个街道的格式: V1 V2单程长度时间 其中V1和V2是街道两端的索引(从0到N-1);一- 方式是1,如果街道从V1…
PAT甲级1107. Social Clusters 题意: 当在社交网络上注册时,您总是被要求指定您的爱好,以便找到一些具有相同兴趣的潜在朋友.一个"社会群体"是一群拥有一些共同兴趣的人.你应该找到所有的集群. 输入规格: 每个输入文件包含一个测试用例.对于每个测试用例, 第一行包含一个正整数N(<= 1000),一个社交网络中的总人数.因此,人数从1到N.然后N行跟随,每个给出一个人的爱好列表的格式: Ki:hi [1] hi [2] ... hi [Ki] 其中Ki(>…
PAT甲级1103. Integer Factorization 题意: 正整数N的K-P分解是将N写入K个正整数的P次幂的和.你应该写一个程序来找到任何正整数N,K和P的N的K-P分解. 输入规格: 每个输入文件包含一个测试用例,它给出一行三个正整数N(<= 400), K(<= N)和P(1 <P <= 7).一行中的数字用空格分隔. 输出规格: 对于每种情况,如果解决方案存在,输出格式如下: N = n1 ^ P + ... nK ^ P 其中ni(i = 1,... K)是…
PAT甲级1098. Insertion or Heap Sort 题意: 根据维基百科: 插入排序迭代,消耗一个输入元素每次重复,并增加排序的输出列表.在每次迭代中,插入排序从输入数据中删除一个元素,在排序列表中找到它所属的位置,并将其插入到其中.它重复,直到没有输入元素保留. 堆排序将其输入分成排序和未排序的区域,并且通过提取最大的元素并将其移动到排序的区域来迭代地缩小未排序的区域.它涉及使用堆数据结构而不是线性时间搜索来查找最大值. 现在给出整数的初始序列, 连同一些序列,这是一些排序方法…