自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 收藏
  • 关注

原创 棋盘覆盖问题

除了排序和检索外,递归还有更广泛的应用。 棋盘覆盖问题 在一个2k^k×2k^k (k≥0)个方格组成的棋盘中,恰有一个方格与其他方格不同,称该方格为特殊方格。显然,特殊方格在棋盘中可能出现的位置有4^k种,因而有4^k种不同的棋盘。棋盘覆盖问题要求用4种不同形状的L型骨牌覆盖给定棋盘上除特殊方格以外的所有方格,且任何2个L型骨牌不得重叠覆盖。 【分析】 1. 我们把棋盘分为左上,左下,右

2017-08-13 23:15:27 464

原创 快速排序

快速排序的基本思想设当前待排序的无序区为 R[low..high],利用分治法可将快速排序的基本思想描述为:1.分解:在 R[low..high]中任选一个记录作为基准(Pivot),以此基准将当前无序区划分为左、右两个较小的子区间 R[low..pivotpos-1)和 R[pivotpos+1..high],并使左边子区间中所有记录的关键字均小于等于基准记录(不妨记为 pivot)的关键字 pi

2017-08-10 20:25:57 239

原创 归并排序

归并排序(Merge sort),是创建在归并操作上的一种有效的排序算法,效率为O(n log n)。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用,且各层分治递归可以同时进行。归并操作 归并操作(merge),也叫归并算法,指的是将两个已经排序的序列合并成一个序列的操作。归并排序算法依赖归并操作。迭代法申请空间,使其大小为两个已经排序序列之和,该空间用来存放合并

2017-08-09 17:23:35 171

原创 以最大连续和为例的算法分析

学习刘汝佳老师的《算法竞赛》总结最大连续和问题 给出一个长度为n的序列A1_{1},A2_{2 },……,An_{n},要求找到1≤\leqi≤\leqj≤\leqn,使得Ai_{i}+Ai+1_{i+1}+……+Aj_{j}尽量大。 一.使用枚举,程序如下:tot = 0; best = A[1]; //初始最大值 for (int i = 1; i <= n; i++)

2017-08-05 12:01:30 275

原创 POJ 1163: The Triangle(dp)

【原题】 Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagona

2017-08-03 15:17:14 226

原创 POJ 2533: Longest Ordered Subsequence

【Problem Description】 A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence (a1, a2, …, aN) be any sequence (ai1, ai2, …, aiK), where 1 <= i1 < i2

2017-08-03 14:22:33 240

原创 Piotr's Ants,UVa 10881

【原题】 Piotr likes playing with ants. He has n of them on a horizontal pole L cm long. Each ant is facing either left or right and walks at a constant speed of 1 cm/s. When two ants bump into each other

2017-08-03 10:26:48 295

原创 Graveyard,NEEEC 2006,LA 3708

在一个周长为10000的圆上等距分布着n个雕塑。现在又有m个新雕塑加入(位置可以随意放),希望所有n+m个雕塑在圆周上均匀分布。这就需要移动其中一些原有的雕塑。要求n个雕塑移动的总距离尽量小。【输入格式】输入包含若干组数据。每组数据仅一行,包含两个整数n和m(2≤n≤1 000,1≤m ≤1 000),即原始的雕塑数量和新加的雕塑数量。输入结束标志为文件结束符(EOF)。【输出格式】输入仅一行,为最

2017-08-02 22:37:56 336

原创 Spreading the Wealth,UVa 11300

【题目】 A Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, everyone has converted all of their properties to coins of

2017-08-02 21:05:33 238

原创 Commando War ,UVa 11729

【题目】 There is a war and it doesn’t look very promising for your country. Now it’s time to act. You have a commando squad at your disposal and planning an ambush on an important enemy camp located nea

2017-08-02 16:59:23 264

原创 The Dragon of Loowater,UVa 11292

【题目】 Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due t

2017-08-02 09:34:03 327

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除