1095 解码PAT准考证/1153 Decode Registration Card of PAT(25 分) PAT 准考证号由 4 部分组成: 第 1 位是级别,即 T 代表顶级:A 代表甲级:B 代表乙级: 第 2~4 位是考场编号,范围从 101 到 999: 第 5~10 位是考试日期,格式为年.月.日顺次各占 2 位: 最后 11~13 位是考生编号,范围从 000 到 999. 现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息. 输入格式: 输入首先在一行中给…
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits…
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits…
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits…
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits…
Source: PAT A1153 Decode Registration Card of PAT (25 分) Description: A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits ar…
Decode Registration Card of PAT PAT-1153 这里需要注意题目的规模,并不需要一开始就存储好所有的满足题意的信息 这里必须使用unordered_map否则会超时 vector的使用需要注意,只有一开始赋予了容量才能读取. 不需要使用set也可以 #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<cst…
A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits…
PAT 准考证号由 4 部分组成: 第 1 位是级别,即 T 代表顶级:A 代表甲级:B 代表乙级: 第 2~4 位是考场编号,范围从 101 到 999: 第 5~10 位是考试日期,格式为年.月.日顺次各占 2 位: 最后 11~13 位是考生编号,范围从 000 到 999. 现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息. 输入格式: 输入首先在一行中给出两个正整数 N(≤)和 M(≤),分别为考生人数和统计要求的个数. 接下来 N 行,每行给出一个考生的准考证号和…
PAT甲级1095. Cars on Campus 题意: 浙江大学有6个校区和很多门.从每个门口,我们可以收集穿过大门的汽车的进/出时间和车牌号码.现在有了所有的信息,你应该在任何特定的时间点告诉在校园停车的数量, 在一天结束时,发现停车时间最长的汽车. 输入规格: 每个输入文件包含一个测试用例.每个案例从两个正整数N(<= 10000)开始,记录数,K(<= 80000)查询次数.然后按N行,每个都以格式记录 plate_number hh:mm:ss status 其中plate_num…
PAT 准考证号由 4 部分组成: 第 1 位是级别,即 T 代表顶级:A 代表甲级:B 代表乙级: 第 2~4 位是考场编号,范围从 101 到 999: 第 5~10 位是考试日期,格式为年.月.日顺次各占 2 位: 最后 11~13 位是考生编号,范围从 000 到 999. 现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息. 输入格式: 输入首先在一行中给出两个正整数 N(≤10​4​​)和 M(≤100),分别为考生人数和统计要求的个数. 接下来 N 行,每行给出一…
PAT 准考证号由 4 部分组成: 第 1 位是级别,即 T 代表顶级:A 代表甲级:B 代表乙级: 第 2~4 位是考场编号,范围从 101 到 999: 第 5~10 位是考试日期,格式为年.月.日顺次各占 2 位: 最后 11~13 位是考生编号,范围从 000 到 999. 现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息. 输入格式: 输入首先在一行中给出两个正整数 N(≤10​4​​)和 M(≤100),分别为考生人数和统计要求的个数. 接下来 N 行,每行给出一…
题意:给出n个车辆进出校园的记录,以及k个时间点,让你回答每个时间点校园内的车辆数,最后输出在校园内停留的总时间最长的车牌号和停留时间,如果不止一个,车牌号按字典序输出. 几个注意点: 1.如果一个车连续多次进入,只取最后一个 2.如果一个车连续多次出去,只取第一个 3.一个车可能出入校园内好几次,停留时间取总和 实际上题目就是让我们求某个时间段内的车辆总和,时间段其实就相当于一个区间,区间求和的话,很快就联想到树状数组和线段树.然而怎么将时间段和区间联系起来呢,那就存储出现在记录和询问里的所有…
一开始没多想,虽然注意到数据N<=10^4的范围,想PAT的应该不会超时吧,就理所当然地用dfs做了,结果最后一组真的超时了.剪枝啥的还是过不了,就意识到肯定不是用dfs做了.直到看到别人说用01背包的思路,果真好久没做题了智力水平下降,且原本dp就是我的弱项,压根就没把这题往dp上去想额... (http://www.liuchuo.net/archives/2323) 题意:从n个硬皮中选取方案,使得总和价值正好为m,如果有多种,方案为排列最小的那个. 可以把硬币看成w=v(即容量=价值)的…
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789810.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~~ 一开始以为是八皇后问题,这不就需要状态压缩dp嘛,PAT没想到竟然还会考这个往后看才发现,原来只是判断是否是八皇后问题的一个解而已. 很明显,八皇后的一个解,每条行.列.对角线最多有1个皇后所以for一遍的时候,相应行.列.对角线的个数++,如果有大于1的,…
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/93135047 1095 Cars on Campus (30 分)   Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing t…
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789828.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~~ 水,中序遍历输出即可注意除根节点.叶子节点外,都需要有括号括起来 #include <iostream> #include <cstdio> #include <algorithm> #include <string>…
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789819.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~~ 题意:用户每次选择一个indice,输出之前出现的频率最高的k个indice如果恰好有两个频率一样,输出indice较小的那个 显然不能每次都要对当前所有的item排个序,会超时的由于每次只要给出前k个出现频率最高的,如果出现频率一样,则给出值最小的所以只要…
计算A+B的和,并且按标准格式处理,每3个就要有个逗号 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int main() { int a,b; scanf("%d %d",&a,&b); int sum=a+b; ]; sprintf(str,"%d"…
注意两点:1.系数也有可能加起来为负!!!一开始我if里面判断为>0导致有样例没过...2.如果最后所有指数的系数都为0,输出一个0即可,原本以为是输出 1 0 0.0... #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; double exps[maxn]; //exps[i]存储结果指数为i的项对…
给出n个城市,m条边,起始点c1和目的点c2接下来给出n个城市的队伍数以及m条双向边问你求c1到c2的所有最短路径数目,以及其中经过的最多队伍数 先最短路dijkstra,同时建立vector数组pre存储前驱节点然后dfs求出路径,以及每条路径经过的队伍数,更新最大值即可 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <s…
统计每层的叶子节点个数建树,然后dfs即可 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; /* 统计每层的叶子节点个数 建树,然后dfs即可 */ ; int n,m; int layer[maxn]; //统计每层的叶子节点个数 ; vector<int…
把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; /* 把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 水 */ ][]={"zero","one&…
判断哪个人最早到,哪个人最晚走水,就是找最大值最小值 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string.h> using namespace std; int m; ],]; ]=]="00:00:00"; int main() { ],time1[],time2[]; scanf(&qu…
题意:给出n个数,求最大连续的子区间和,并且输出该区间的第一个和最后一个数. 如果所有数都小于0,那么则输出0,第一个数和最后一个数. 看数据k的范围,就知道肯定不能两层for循环来求区间和,O(n^2)的复杂度肯定超时所以这里肯定要求一遍for循环就能知道结果定义区间l和r,sum为目前[l,r]之间的和一开始l=r=0,sum=a[0]接下来,对于当前第i个数字a[i]如果sum+a[i]>a[i],那么就将a[i]一起加入到区间中去.如果sum+a[i]<a[i],那么还不如不加,直接重…
如题... #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string.h> using namespace std; //太水了好吧... int n; ; ; int main() { scanf("%d",&n); ; int now; ; ;i<n;i++){ scanf(&q…
多项式相乘 注意相乘结果的多项式要开两倍的大小!!! #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string.h> using namespace std; //两个多项式相乘 +; int k; //原本定义个exp导致编译错误,没想到定义成exp1.exp2也会编译错误,估计引起函数名冲突了 double ex…
题意:给出n1和n2,以及其中一个数的进制,问另一个数是多少进制的情况下,才会是两个数相等.不存在的话,则输出Impossible 这题思路很简单,但是要考虑的比较多,在简单题里面算是比较好的. 有两个注意点1.我被题目给骗了!!!以为最大进制只可能是36,所以在程序里就枚举2~36的进制,导致错了一大片样例最小进制下界low当然是n2的最大数字位+1最大进制上界high题目没有给出说明,但最大只可能为n1(前提n1>=low).为啥不会超过n1呢,比如40 10 1 10很明显10是进制表示除…
题目不严谨啊啊啊啊式子算出来结果是37.975样例输出的是37.98我以为是四舍五入的啊啊啊,所以最后输出的是sum+0.005结果告诉我全部错误啊结果直接保留两位小数就可以了啊啊啊啊 水题也不要这么坑人啊啊啊啊 #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; int main() { ]; double su…
排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较.更新 至于查询,建立id与索引的映射即可. #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <map> using namespace s…