
算法与数据结构
IT研究僧大师兄
做我应该做的,学我兴趣所在的。
展开
-
1003 Emergency
1003 Emergency (25 分)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams ...原创 2019-03-16 23:19:26 · 232 阅读 · 0 评论 -
B - Ugly Numbers(1.5.8)
DescriptionUgly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, ... shows the first 10 ugly numbers. By convention, 1 is included. G原创 2014-07-16 13:12:58 · 795 阅读 · 0 评论 -
C - 排列(1.5.9)
Description题目描述:大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六个排列。任务描述:给出某个排列,求出这个排列的下k个排列,如果遇到最后一个排列,则下1排列为第1个排列,即排列1 2 3…n。比如:n = 3,k原创 2014-07-16 15:40:30 · 924 阅读 · 0 评论 -
STL系列问题--全排列
曾看到百度迅雷笔试题中有全排列的问题。原创 2014-07-16 15:43:58 · 710 阅读 · 0 评论 -
E - Speed Limit(2.1.1)
DescriptionBill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can原创 2014-07-16 17:23:28 · 672 阅读 · 0 评论 -
F - Ride to School(2.1.2)
DescriptionMany graduate students of Peking University are living in Wanliu Campus, which is 4.5 kilometers from the main campus – Yanyuan. Students in Wanliu have to either take a bus or ride a b原创 2014-07-16 20:03:06 · 809 阅读 · 0 评论 -
G - Self Numbers(2.2.1)
DescriptionIn 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d原创 2014-07-16 20:50:15 · 644 阅读 · 0 评论 -
H - Gold Coins(2.4.1)
DescriptionThe king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two days (the second and third days of service), th原创 2014-07-17 09:15:05 · 830 阅读 · 0 评论 -
I - The 3n + 1 problem(2.4.2)
DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an a原创 2014-07-17 09:44:42 · 640 阅读 · 0 评论 -
J - Vertical Histogram(1.5.7)
DescriptionWrite a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print a vertical histogram that sho原创 2014-07-13 19:41:29 · 936 阅读 · 0 评论 -
I - Dirichlet's Theorem on Arithmetic Progressions(1.5.5)
DescriptionIf a and d are relatively prime positive integers, the arithmetic sequence beginning witha and increasing by d, i.e., a, a + d,a + 2d, a + 3d, a + 4d, ..., contains infinitely man原创 2014-07-13 18:51:14 · 579 阅读 · 0 评论 -
H - Quicksum(1.5.3)
DescriptionA checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often us原创 2014-07-13 18:14:13 · 538 阅读 · 0 评论 -
数组a中有n个元素,从其中选出m个元素,输出这m个元素所有不同的组合
题目:数组a中有n个元素,从其中选出m(m < n)个元素,输出这m个元素所有不同的组合分析:举例如:1 2 3 4 5从中选出任意3个数的组合分别为:1 2 31 2 41 2 51 3 41 3 51 4 52 3 42 3 52 4 53 4 5观察上述例子中,选择的步骤是这样的:从{1, 2, 3, 4, 5}中任意选出第1个元素,如选出了1,然后...原创 2018-11-13 11:36:00 · 6654 阅读 · 1 评论 -
A - Financial Management(1.1.1)
/*DescriptionLarry graduated this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial port原创 2014-07-13 15:15:39 · 1312 阅读 · 0 评论 -
B - Doubles(1.2.1)
B - Doubles(1.2.1)Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmitStatusDescriptionAs part of an arithmetic competency program, your students will be原创 2014-07-13 15:22:35 · 655 阅读 · 0 评论 -
C - Sum of Consecutive Prime Numbers(1.2.2)
C - Sum of Consecutive Prime Numbers(1.2.2)Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmitStatusDescriptionSome positive integers can be represented by原创 2014-07-13 15:25:51 · 1117 阅读 · 0 评论 -
D - I Think I Need a Houseboat(1.3.1)
D - I Think I Need a Houseboat(1.3.1)Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmitStatusDescriptionFred Mapper is considering purchasing some lan原创 2014-07-13 15:27:09 · 647 阅读 · 0 评论 -
E - Hangover(1.4.1)
DescriptionHow far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're assuming that the cards must be perpendic原创 2014-07-13 15:57:36 · 558 阅读 · 0 评论 -
F - Humidex(1.4.2)
DescriptionAdapted from Wikipedia, the free encyclopediaThe humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and humidity. It differs from the he原创 2014-07-13 16:49:53 · 627 阅读 · 0 评论 -
G - Specialized Four-Digit Numbers(1.5.2)
DescriptionFind and list all four-digit numbers in decimal notation that have the property that the sum of its four digits equals the sum of its digits when represented in hexadecimal (base 16) no原创 2014-07-13 17:27:23 · 578 阅读 · 0 评论 -
A - Red and Black(3.2.1)
DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent til原创 2014-07-17 16:44:56 · 662 阅读 · 0 评论 -
B - Symmetric Order(3.3.1)
DescriptionIn your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a list of names in nondescending order by lengt原创 2014-07-17 17:06:18 · 752 阅读 · 0 评论 -
C - Maya Calendar(4.7.4)
DescriptionDuring his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a原创 2014-07-24 11:36:24 · 639 阅读 · 0 评论 -
A - Nearest Common Ancestors(8.1.1)
DescriptionA rooted tree is a well-known data structure in computer science and engineering. An example is shown below:In the figure, each node is labeled with an integer from {1, 2,...,16原创 2014-07-28 15:29:57 · 584 阅读 · 0 评论 -
A - Hire and Fire(8.1.2)
DescriptionIn this problem, you are asked to keep track of the hierarchical structure of an organization's changing staff. As the first event in the life of an organization, the Chief Executive原创 2014-07-29 17:02:14 · 1254 阅读 · 0 评论 -
ACM-ICPC集训--数学基础知识
感谢cnblogs的_kuangbin博主提供这么好的文章,转载过来学习使用。原文博客地址http://www.cnblogs.com/kuangbin/archive/2012/08/28/2661066.html从放暑假前周sir给我讲了一个用polya计数法和burnside定理做的题目(pku2409)后,突然觉得组合数学挺有意思,然后从那时起到现在几乎都在做这类的题目转载 2015-01-25 22:11:26 · 2374 阅读 · 0 评论 -
经典排序算法总结(代码)
经典排序算法总结(代码)--fly分享目录/*冒泡法....2/*快速排序....3/*插入排序....4/*希尔(shell)排序....5/*选择排序/*堆排序/*归并排序 附:排序算法原理:http://zh.wikipedia.org/wiki/Category:%E6%8E%92%E5%BA%8F%E7%AE%97%E转载 2014-07-20 12:49:29 · 1061 阅读 · 0 评论 -
递归算法学习---归并排序
分而治之的概念 分而治之是一种使用递归解决问题的算法,主要的技巧是将一个大的复杂的问题划分为多个子问题,而这些子问题可以作为终止条件,或者在一个递归步骤中得到解决,所有子问题的解决结合起来就构成了对原问题的解决 2. 分而治之的优点和缺点 分而治之算法通常包括一个或者多个递归方法的调用,当这些调用将数据分隔成为独立的集合从而处理较小集合转载 2014-07-23 10:31:55 · 2371 阅读 · 0 评论 -
C++ STL 中 map 容器的说明和使用技巧
Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作! 1、map简介map是一类关联式容器。它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响。对于迭代器来说,可以修改实值,而不能修改key。 2、map的功能自动转载 2014-07-22 10:04:02 · 17189 阅读 · 3 评论 -
神、上帝以及老天爷
神、上帝以及老天爷Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Font Size: ← →Problem DescriptionHDU 2006'10 ACM contest的颁奖晚会隆重开始了!为了活跃气氛,组织者举行了一个别开生面、奖品丰厚的抽奖活动,这个活动原创 2014-05-20 15:20:47 · 1188 阅读 · 0 评论 -
A - Babelfish(6.1.2)(6.1使用词典解题实验范例)
DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand the原创 2014-07-24 09:41:34 · 881 阅读 · 0 评论 -
C - Ultra-QuickSort(7.2.2)
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the seq原创 2014-07-23 14:28:19 · 749 阅读 · 0 评论 -
B - Who's in the Middle(7.1.2)
DescriptionFJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as much or more than the median; half give as much o原创 2014-07-23 09:17:20 · 749 阅读 · 0 评论 -
C - Fractal(3.4.1)
DescriptionA fractal is an object or quantity that displays self-similarity, in a somewhat technical sense, on all scales. The object need not exhibit exactly the same structure at all scales, but原创 2014-07-17 19:22:17 · 730 阅读 · 0 评论 -
D - Sticks(3.4.2)
#include #include #include using namespace std;int n, p[65];bool pj[65];bool cmp(int a,int b){ return a>b;}int solve( int per, int remain, int m ){ if( remain == 0 && m == 0)原创 2014-07-18 11:19:18 · 593 阅读 · 0 评论 -
A - Calendar(4.1.1)
DescriptionA calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The terms of hour, day, month, year and century are all units原创 2014-07-18 15:35:52 · 864 阅读 · 0 评论 -
B - Adding Reversed Numbers(4.2.1)
DescriptionThe Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Therefore the dramatic advisor of ACM has decided to transfigure原创 2014-07-18 18:10:08 · 806 阅读 · 0 评论 -
C - Modular multiplication of polynomials(4.3.2)
DescriptionConsider polynomials whose coefficients are 0 and 1. Addition of two polynomials is achieved by 'adding' the coefficients for the corresponding powers in the polynomials. The addition o原创 2014-07-20 11:44:32 · 798 阅读 · 0 评论 -
D - Blue Jeans(4.6.1)
题意:求最长公共字符串。如果最大长度小与3,则输出no significant commonalities.反之输出最长的这个串。 分析:枚举公共字符串的长度,然后再第2到N串中找是否存在字符串1中相应长度的子串。 知识点整理: 1、 包含文件:string.h 函数名: strstr 函数原型:extern char *strstr(c原创 2014-07-20 13:29:19 · 816 阅读 · 0 评论 -
A - Oulipo(4.6.2)
DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter'e'. He was a member of the Oulipo group. A quote from the book:Tout avait Pair原创 2014-07-20 18:18:13 · 719 阅读 · 0 评论