摘要: 7 1 Knuth洗牌法 (20分) Knuth 洗牌法是生成 { 1, 2, ..., n } 的一个随机重排列的算法。与每次反复随机生成一个数字,直到获得一个不重复的新数字的算法不同,Knuth 洗牌法从原始序列 { 1, 2, ..., n } 开始,逐次洗牌。洗牌的方法是从左到右,每轮从没确 阅读全文
posted @ 2020-05-02 11:47 yxdh 阅读(926) 评论(0) 推荐(0) 编辑
摘要: 785. 快速排序 给定你一个长度为n的整数数列。 请你使用快速排序对这个数列按照从小到大进行排序。 并将排好序的数列按顺序输出。 输入格式 输入共两行,第一行包含整数 n。 第二行包含 n 个整数(所有整数均在1~109 范围内),表示整个数列。 输出格式 输出共一行,包含 n 个整数,表示排好序 阅读全文
posted @ 2020-03-18 23:51 yxdh 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 787. 归并排序 给定你一个长度为n的整数数列。 请你使用归并排序对这个数列按照从小到大进行排序。 并将排好序的数列按顺序输出。 输入格式 输入共两行,第一行包含整数 n。 第二行包含 n 个整数(所有整数均在1~109 范围内),表示整个数列。 输出格式 输出共一行,包含 n 个整数,表示排好序 阅读全文
posted @ 2020-03-18 23:29 yxdh 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1150 Travelling Salesman Problem (25分) The "travelling salesman problem" asks the following question: "Given a list of cities and the distances betwee 阅读全文
posted @ 2020-03-15 23:47 yxdh 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1148 Werewolf Simple Version (20分) Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. 阅读全文
posted @ 2020-03-14 23:26 yxdh 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1154 Vertex Coloring (25分) A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices sharing the same edge 阅读全文
posted @ 2020-03-13 00:31 yxdh 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 1153 Decode Registration Card of PAT (25分) A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T 阅读全文
posted @ 2020-03-13 00:27 yxdh 阅读(244) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2020-03-12 11:42 yxdh 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1105 Spiral Matrix (25分) This time your job is to fill a sequence of N positive integers into a spiral matrix in non increasing order. A spiral matrix 阅读全文
posted @ 2020-03-11 23:14 yxdh 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 1087 All Roads Lead to Rome (30分) Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the rout 阅读全文
posted @ 2020-03-11 22:39 yxdh 阅读(192) 评论(0) 推荐(0) 编辑