![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
OJ题解
文章平均质量分 70
选取了各个OJ平台上的算法或者思维题,题解以python为主
Hikari_zly
个人学习用
展开
-
Codeforces Round #702 (Div. 3)补题
题目链接文章目录A. Dense ArrayB. Balanced RemaindersC. Sum of CubesD. Permutation TransformationA. Dense ArrayPolycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any i (1≤i原创 2021-02-20 01:38:31 · 817 阅读 · 1 评论 -
Codeforces Round #690 (Div. 3)补题
题目链接文章目录A. Favorite SequenceB. Last Year's SubstringC. Unique NumberD. Add to Neighbour and RemoveE2. Close Tuples (hard version)F. The Treasure of The SegmentsA. Favorite SequencePolycarp has a favorite sequence a[1…n] consisting of n integers. He wrot原创 2021-02-06 00:41:59 · 486 阅读 · 1 评论 -
Codeforces Round #697 (Div. 3)补题
题目链接A. Odd DivisorYou are given an integer n. Check if n has an odd divisor, greater than one (does there exist such a number x (x>1) that n is divisible by x and x is odd).For example, if n=6, then there is x=3. If n=4, then such a number does not e原创 2021-02-06 00:07:58 · 381 阅读 · 0 评论 -
51Nod 2738 选数字 python题解
题目链接题目描述从1-n中选出m个数,要求同样的数字不能重复选择,按照字典序正序输出所有方案。例如:从1到4中选出2个数,共有6种方法,按照字典序输出,依次为:1 21 31 42 32 43 4输入样例4 2输出样例1 21 31 42 32 43 4思路这道题其实就是组合问题,可以用DFS,但是这里也可以直接调用python中的itertools模块。运用combinations(iterable, r) 创建一个迭代器,返回iterable中所有长度为r的子原创 2021-02-03 01:28:02 · 743 阅读 · 0 评论 -
51Nod 2282 树的深度 python题解
题目链接题目描述:给出一棵n个节点的树,节点编号为1-n(根节点编号为1,且根节点深度为1),求这棵树的深度(树中节点的最大层次)。例如:1─2─4─5└─3其中1-2-4-5这条边是最长的,所以树的深度为4。输入第一行:1个数n(1 < n <= 1000),表示树的节点数量。后面n-1行:每行2个数x y,表示节点x是节点y的父节点(1 <= x, y <= n)。输出输出1个数,表示这棵树的深度输入样例51 21 32 44 5输出样例4原创 2021-02-02 20:51:19 · 396 阅读 · 0 评论 -
计蒜客 T1212 仙岛求药 python题解
问题描述:少年李逍遥的婶婶病了,王小虎介绍他去一趟仙灵岛,向仙女姐姐要仙丹救婶婶。叛逆但孝顺的李逍遥闯进了仙灵岛,克服了千险万难来到岛的中心,发现仙药摆在了迷阵的深处。迷阵由 M×N个方格组成,有的方格内有可以瞬秒李逍遥的怪物,而有的方格内则是安全。现在李逍遥想尽快找到仙药,显然他应避开有怪物的方格,并经过最少的方格,而且那里会有神秘人物等待着他。现在要求你来帮助他实现这个目标。输入格式:输入有多组测试数据. 每组测试数据以两个非零整数 M 和 N 开始,两者均不大于20。M 表示迷阵行数, N 表示原创 2021-01-26 20:54:12 · 426 阅读 · 0 评论