摘要: 题目描述: In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If ci 阅读全文
posted @ 2017-12-02 12:03 505算法小菜` 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 有n个整数(1<=n<=200000),分别为a1, a2, a3, ..., an。对于第i个整数ai,它的范围为0~10^9, 有k个整数(1<=k<=200000),分别为M1, M2, M3, ..., Mk。对于第i个整数Mi,它的范围为0~10^9。你的任务是对M1, M2, 阅读全文
posted @ 2017-11-22 21:36 505算法小菜` 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 回文词是一种对称的字符串。任意给定一个字符串,通过插入若干字符,都可以变成回文词。此题的任务是,求出将给定字符串变成回文词所需要插入的最少字符数。 比如 “Ab3bd”插入2个字符后可以变成回文词“dAb3bAd”或“Adb3bdA”,但是插入少于2个的字符无法变成回文词。 注:此问题区 阅读全文
posted @ 2017-11-21 22:17 505算法小菜` 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. About every da 阅读全文
posted @ 2017-11-21 22:02 505算法小菜` 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 一个除1以外的正整数都能被分解为若干个质因子的乘积。比如24 = 2 * 2 * 2 * 3。现在给你m, n, 求[m, n]内的所有正整数被分解为质因子的个数总和。 例如 : m = 5, n = 9时 : 5 = 5 1 6 = 2 * 3 2 7 = 7 1 8 = 2 * 2 阅读全文
posted @ 2017-11-19 22:16 505算法小菜` 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 题目描述: On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange 阅读全文
posted @ 2017-11-16 08:56 505算法小菜` 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 题目描述:One day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1 people take 阅读全文
posted @ 2017-11-15 22:53 505算法小菜` 阅读(451) 评论(0) 推荐(0) 编辑
摘要: 注意:看这篇随笔之前请先看之前写的《最短路径之迪杰特斯拉算法》。在上一篇随笔中,我们了解到了迪杰特斯拉算法,不知道大家发现了没有,该算法算的是单源路径,也就是已经确定好了所求最短路径的起点城市,因此我们只使用了一维数组p[i],T[i],其实,这已经默认了是P[1][i]和T[1][i],也就是从一 阅读全文
posted @ 2017-07-09 14:25 505算法小菜` 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 回文串,就是从前往后和从后往前看都是一样的字符串。那么现在给你一个字符串,请你找出该字符串中,长度最大的一个回文子串。 输入描述: 有且仅有一个仅包含小写字母的字符串,保证其长度不超过5000 输出描述: 有且仅有一个正整数,表示最长回文子串的长度 输入样例: abccbxyz 输出样例 阅读全文
posted @ 2017-07-08 19:03 505算法小菜` 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 有n个数,请你找出第k小的数。 输入描述: 第一行有2个正整数n,k(n,k<=10^7)第二行有n个非负数ai(ai<=10^5) 输出描述: 输出第k小的数。 输入样例: 5 21 5 3 4 5 输出样例: 3 题目分析: 这道题目言简意赅,其实很明显我们就能想到一种解法:就是排序 阅读全文
posted @ 2017-07-07 10:59 505算法小菜` 阅读(149) 评论(0) 推荐(0) 编辑