摘要: dfs求最大层数并查集求连通个数 #include <iostream> #include <cstdio> #include <algorithm> #include <string.h> #include <string> #include <vector> using namespace st 阅读全文
posted @ 2017-04-18 15:31 辰曦~文若 阅读(304) 评论(0) 推荐(0) 编辑
摘要: n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题。。。 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespa 阅读全文
posted @ 2017-04-18 15:27 辰曦~文若 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 有n个客户和k个窗口,给出n个客户的到达时间和需要的时长有空闲的窗口就去办理,没有的话就需要等待,求客户的平均时长。如果在8点前来的,就需要等到8点。如果17点以后来的,则不会被服务,无需考虑。 按客户的到达时间排序建立一个优先级队列,一开始放入k个窗口,初始结束时间为8*3600然后for循环客户 阅读全文
posted @ 2017-04-18 15:24 辰曦~文若 阅读(1083) 评论(4) 推荐(0) 编辑
摘要: 先判断n是否为素数然后把n转化成d进制下再反转,转化为十进制的num判断num是否为素数 注意n为0和1时,不是素数!!!注意反转后的num也有可能为1,不是素数!!! #include <iostream> #include <cstdio> #include <algorithm> #inclu 阅读全文
posted @ 2017-04-18 15:21 辰曦~文若 阅读(362) 评论(0) 推荐(0) 编辑
摘要: 题目就是求联通分支个数删除一个点,剩下联通分支个数为cnt,那么需要建立cnt-1边才能把这cnt个联通分支个数求出来怎么求联通分支个数呢可以用并查集,但并查集的话复杂度是O(m*logn*k)我这里用的是dfs,dfs的复杂度只要O((m+n)*k)这里k是指因为有k个点要查询,每个都要求一下删除 阅读全文
posted @ 2017-04-18 15:19 辰曦~文若 阅读(441) 评论(0) 推荐(0) 编辑
摘要: 排序,水题因为最后如果一个学生最好的排名有一样的,输出的课程有个优先级A>C>M>E那么按这个优先级顺序进行排序每次排序前先求当前课程的排名然后再与目前最好的排名比较、更新 至于查询,建立id与索引的映射即可。 #include <iostream> #include <algorithm> #in 阅读全文
posted @ 2017-04-18 15:16 辰曦~文若 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 题目不严谨啊啊啊啊式子算出来结果是37.975样例输出的是37.98我以为是四舍五入的啊啊啊,所以最后输出的是sum+0.005结果告诉我全部错误啊结果直接保留两位小数就可以了啊啊啊啊 水题也不要这么坑人啊啊啊啊 #include <iostream> #include <algorithm> #i 阅读全文
posted @ 2017-04-18 15:13 辰曦~文若 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n1和n2,以及其中一个数的进制,问另一个数是多少进制的情况下,才会是两个数相等。不存在的话,则输出Impossible 这题思路很简单,但是要考虑的比较多,在简单题里面算是比较好的。 有两个注意点1.我被题目给骗了!!!以为最大进制只可能是36,所以在程序里就枚举2~36的进制,导致错了 阅读全文
posted @ 2017-04-18 15:11 辰曦~文若 阅读(864) 评论(2) 推荐(0) 编辑
摘要: 多项式相乘 注意相乘结果的多项式要开两倍的大小!!! #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string.h> using namespace std; //两个 阅读全文
posted @ 2017-04-18 15:07 辰曦~文若 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 如题。。。 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string.h> using namespace std; //太水了好吧。。。 int n; int tim 阅读全文
posted @ 2017-04-18 15:05 辰曦~文若 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题意:给出n个数,求最大连续的子区间和,并且输出该区间的第一个和最后一个数。 如果所有数都小于0,那么则输出0,第一个数和最后一个数。 看数据k的范围,就知道肯定不能两层for循环来求区间和,O(n^2)的复杂度肯定超时所以这里肯定要求一遍for循环就能知道结果定义区间l和r,sum为目前[l,r] 阅读全文
posted @ 2017-04-18 15:01 辰曦~文若 阅读(455) 评论(0) 推荐(1) 编辑
摘要: 判断哪个人最早到,哪个人最晚走水,就是找最大值最小值 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string.h> using namespace std; int 阅读全文
posted @ 2017-04-18 14:59 辰曦~文若 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 把每个位上的数字求和sum,然后以英文单词的形式输出sum的每个位 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; 阅读全文
posted @ 2017-04-18 14:57 辰曦~文若 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 统计每层的叶子节点个数建树,然后dfs即可 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; /* 统计每层的叶子节 阅读全文
posted @ 2017-04-18 14:56 辰曦~文若 阅读(422) 评论(0) 推荐(0) 编辑
摘要: 注意两点:1.系数也有可能加起来为负!!!一开始我if里面判断为>0导致有样例没过。。。2.如果最后所有指数的系数都为0,输出一个0即可,原本以为是输出 1 0 0.0。。。 #include <iostream> #include <cstdio> #include <algorithm> #in 阅读全文
posted @ 2017-04-18 14:53 辰曦~文若 阅读(586) 评论(0) 推荐(0) 编辑
摘要: 计算A+B的和,并且按标准格式处理,每3个就要有个逗号 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int main() { int a,b; s 阅读全文
posted @ 2017-04-18 14:51 辰曦~文若 阅读(943) 评论(0) 推荐(0) 编辑