摘要: 题目大意:给定一个闭区间,问这个区间内有没有满足各数位数字不相等的数,有的话输出任意一个,没有的话输出 -1. 阅读全文
posted @ 2019-09-30 08:06 ZSsst 阅读(125) 评论(0) 推荐(1) 编辑
摘要: 康拓展开 给出一个全排列,求他是第几个全排列称为康拓展开。 暴力康拓展开 对于一个全排列来说,从左往右第i位,有 n + 1 - i 种选择。如果用变进制数表示的话,这一位就是 n + 1 - i 进制的数,如果这一位选择了第k种情况,那么对应的这一位就是k。(k从0开始) 比如:1 4 5 2 3 阅读全文
posted @ 2019-08-14 08:54 ZSsst 阅读(292) 评论(0) 推荐(0) 编辑
摘要: dij SPFA 负环和差分约束之前写程序设计作业的时候就了解过spfa和差分约束,这里再解释一下 负环: 一个边权和为复数的环称为负环。不难知道,如果图中存在负环,那么无论经过多少次迭代,总存在有向边(x,y,z)使得dist[y] > dist[x] + z则spfa算法无法结束。 根据抽屉原理 阅读全文
posted @ 2019-08-12 09:21 ZSsst 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undirected graph 阅读全文
posted @ 2019-08-12 09:19 ZSsst 阅读(116) 评论(0) 推荐(0) 编辑
摘要: There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say t 阅读全文
posted @ 2019-08-12 09:18 ZSsst 阅读(163) 评论(0) 推荐(0) 编辑
摘要: You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write 阅读全文
posted @ 2019-08-12 09:16 ZSsst 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 克鲁斯卡尔 普里姆 阅读全文
posted @ 2019-08-12 09:14 ZSsst 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Trie树 Trie树是一种用于实现字符串快速检索的多叉树结构。Trie的每个节点都拥有若干个字符指针,若在插入或检索字符串时扫描到一个字符c,就沿着当前节点的c字符指针,走向该指针指向的节点。 初始化 一棵空Trie仅包含一个根节点,该点的字符指针均指向空。 插入 当需要插入一个字符串S时,我们令 阅读全文
posted @ 2019-07-09 15:42 ZSsst 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Python 3.6.3共有33个保留关键字,可以在IDLE上连续执行如下代码,查看Python的关键字。 1 import keyword 2 keyword.kwlist 这些关键字不能用于变量名,函数名,类名等,它们属于Python语言本身的专用标识符,所以叫保留关键字。 阅读全文
posted @ 2019-07-09 15:25 ZSsst 阅读(524) 评论(0) 推荐(1) 编辑
摘要: 多行语句 Python语言一般一行写完一条语句,但是当一条语句过长时,可以使用斜杠(\)将一行的语句分为多行显示: 1 one_price = 10 2 two_price = 20 3 three_price = 30 4 total = one_price +\ 5 two_price +\ 6 阅读全文
posted @ 2019-07-09 15:17 ZSsst 阅读(2083) 评论(0) 推荐(0) 编辑