2013年2月14日

Strange Towers of Hanoi(DP,汉诺塔)

摘要: Strange Towers of HanoiTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 2195Accepted: 1446DescriptionBackground Charlie Darkbrown sits in another one of those boring Computer Science lessons: At the moment the teacher just explains the standard Tower of Hanoi problem, which bores Charlie to 阅读全文

posted @ 2013-02-14 23:38 铁树银花 阅读(672) 评论(0) 推荐(0) 编辑

汉诺塔通项公式

摘要: 汉诺塔问题家传户晓,其问题背景不做详述,此处重点讲解在有3根柱子的情况下,汉诺塔问题求解的通项公式的推导。问题背景:有A,B和C三根柱子,开始时n个大小互异的圆盘从小到大叠放在A柱上,现要将所有圆盘从A移到C,在移动过程中始终保持小盘在大盘之上。求移动盘子次数的最小值。变量设置:n为圆盘个数,H(k)为n=k时移动盘子次数的最小值。递推公式: H(k)=2H(k-1)+1。通项公式:H(k)=2^k-1。证明:(1)证明递推公式:首先被移动到C盘的必定是最大的盘子,否则必定违反“在移动过程中始终保持小盘在大盘之上”的规定。既然要将最大盘移动到C,此时最大盘之上必定没有任何盘子,亦即它独自在一根 阅读全文

posted @ 2013-02-14 23:19 铁树银花 阅读(6144) 评论(0) 推荐(0) 编辑

World Cup Noise(DP基础)

摘要: World Cup NoiseTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 13853Accepted: 6827DescriptionBackground "KO-RE-A, KO-RE-A" shout 54.000 happy football fans after their team has reached the semifinals of the FIFA World Cup in their home country. But although their excitement is rea 阅读全文

posted @ 2013-02-14 17:35 铁树银花 阅读(572) 评论(0) 推荐(0) 编辑

Recaman's Sequence(简单)

摘要: Recaman's SequenceTime Limit: 3000MS Memory Limit: 60000KTotal Submissions: 19147 Accepted: 8028DescriptionThe Recaman's sequence is defined by a0 = 0 ; for m > 0, am = am−1 − m if the rsulting am is positive and not already in the sequence, otherwise am = am−1 + m. The first few numbers 阅读全文

posted @ 2013-02-14 11:16 铁树银花 阅读(431) 评论(0) 推荐(0) 编辑

2013年2月13日

Function Run Fun(简单)

摘要: Function Run FunTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 13734Accepted: 7154DescriptionWe all love recursion! Don't we? Consider a three-parameter recursive function w(a, b, c):if a <= 0 or b <= 0 or c <= 0, then w(a, b, c) returns:1if a > 20 or b > 20 or c > 20 阅读全文

posted @ 2013-02-13 23:49 铁树银花 阅读(1735) 评论(0) 推荐(0) 编辑

The Triangle(DP基础)

摘要: The TriangleTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 31614Accepted: 18667Description73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends so... 阅读全文

posted @ 2013-02-13 22:27 铁树银花 阅读(324) 评论(0) 推荐(0) 编辑

01背包

摘要: 问题描述: 有N件物品和一个载重量为C的背包。第i件物品的重量是w[i],价值是v[i]。求解将哪些物品装入背包可使这些物品的重量总和不超过背包容量,且价值总和最大。问题特点: 每种物品仅有一件,可以选择放或不放。(0:不放 1:放)基本思路: 用p[i][j]表示前i件物品放入一个容量为j的背包中可以获得的最大价值。得到如下关系: 1.p[i][0] = p[0][j] = 0 ··········· (1) 2.p[i][j] = p[i - 1][j] (当j < w[i] 阅读全文

posted @ 2013-02-13 17:06 铁树银花 阅读(181) 评论(0) 推荐(0) 编辑

2013年2月7日

Safecracker(暴力)

摘要: SafecrackerTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5240Accepted Submission(s): 2622Problem Description=== Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Klein safe behind a painting in the second-floor library. Kle 阅读全文

posted @ 2013-02-07 00:17 铁树银花 阅读(1446) 评论(0) 推荐(1) 编辑

2013年2月6日

error: expected unqualified-id before 'int'

摘要: 出错现场: bool i, int j;将逗号改成分号即可。C/C++不能在同一条语句中定义不同类型的变量。 阅读全文

posted @ 2013-02-06 21:18 铁树银花 阅读(1086) 评论(0) 推荐(0) 编辑

2013年1月30日

截尾平均数及利用SPSS求截尾平均数

摘要: 由于平均数受到极端值的影响较大,因此可以考虑将数据排序后,按照一定的比例截去两端的值,使用余下的数据求取平均值,这样得到的平均数称为截尾均数。 如果截尾均数和平均数的差异不大,表明原数据存在极端数据的情况不严重,或两侧极端值相抵消;反之则说明原数据存在极端数据,使用截尾平均数更能反应数据的集中趋势。 常用的截尾比例为5%,即排序后两端各去掉5%的数据。 SPSS的Explore过程能自动完成5%截尾均值的求取。例子:将一组身高数据Height(label:Height/cm)输入SPSS: 依次选择Analyze——Descriptive Statistics——Explore,出现在右侧.. 阅读全文

posted @ 2013-01-30 13:17 铁树银花 阅读(2434) 评论(0) 推荐(0) 编辑

2013年1月28日

Oil Deal(最大生成树)

摘要: ZOJ Problem Set - 2677Oil DealTime Limit: 5 Seconds Memory Limit: 32768 KB Special JudgeOil is a very important strategic resource. Recently United Statesof Antarctica invaded the rich in oil country of Qari, and now tryto keep the control of the oil transportation system. The systemconsists of p... 阅读全文

posted @ 2013-01-28 22:40 铁树银花 阅读(266) 评论(0) 推荐(0) 编辑

2013年1月27日

Can you solve this equation?(二分查找的简单应用)

摘要: Can you solve this equation?Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionNow,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100;Now please try your lucky.InputThe first line of the input contains an inte 阅读全文

posted @ 2013-01-27 11:15 铁树银花 阅读(198) 评论(0) 推荐(0) 编辑

2013年1月26日

Tempter of the Bone(DFS+奇偶剪枝)

摘要: Tempter of the BoneTime Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized th 阅读全文

posted @ 2013-01-26 22:04 铁树银花 阅读(216) 评论(0) 推荐(0) 编辑

LETTERS(搜索题)

摘要: LETTERSTime Limit:1000MSMemory Limit:10000KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionA single-player game is played on a rectangular board divided in R rows and C columns. There is a single uppercase letter (A-Z) written in every position in the board.Before the begging of the game th 阅读全文

posted @ 2013-01-26 13:55 铁树银花 阅读(334) 评论(0) 推荐(0) 编辑

棋盘问题(简单的搜索题)

摘要: A - 棋盘问题Time Limit:1000MSMemory Limit:10000KB64bit IO Format:%I64d & %I64uSubmitStatusDescription在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n当为-1 阅读全文

posted @ 2013-01-26 11:44 铁树银花 阅读(395) 评论(0) 推荐(0) 编辑

2013年1月23日

MATLAB描绘极坐标图像——polar

摘要: polar可用于描绘极坐标图像。最简单而常用的命令格式:POLAR(THETA, RHO)其中,THETA是用弧度制表示的角度,RHO是对应的半径。例:a=-2*pi:.001:2*pi; %设定角度b=(1-sin(a)); %设定对应角度的半径polar(a, b,'r') %绘图得到这也是传说中笛卡尔最后一封情书中蕴含的秘密借这个曲线献给爱妻❤ 阅读全文

posted @ 2013-01-23 11:06 铁树银花 阅读(1205) 评论(0) 推荐(0) 编辑

2013年1月22日

MATLAB求实数绝对值——abs

摘要: abs(X)命令可用于X中元素的绝对值。例1.>> X=[1,-1;9,-98];>> abs(X)ans = 1 1 9 98例2.>> abs(-1)ans = 1 阅读全文

posted @ 2013-01-22 18:06 铁树银花 阅读(1117) 评论(0) 推荐(0) 编辑

matlab图像处理函数大全

摘要: 1、图像的变换① fft2:fft2函数用于数字图像的二维傅立叶变换,如:i=imread('104_8.tif');j=fft2(i);②ifft2::ifft2函数用于数字图像的二维傅立叶反变换,如:i=imread('104_8.tif');j=fft2(i);k=ifft2(j);2、模拟噪声生成函数和预定义滤波器① imnoise:用于对图像生成模拟噪声,如:i=imread('104_8.tif');j=imnoise(i,'gaussian',0,0.02);%模拟高斯噪声② fspecial:用于产生预定义滤波器, 阅读全文

posted @ 2013-01-22 17:26 铁树银花 阅读(5235) 评论(0) 推荐(3) 编辑

MATLAB——zeros

摘要: zeros可用于创建所有元素均为0的矩阵。1.zeros(N)创建一个N*N的矩阵,其中所有元素均为0。2.zeros(M,N)创建一个M*N的矩阵,其中所有元素均为0.3.zeros(SIZE(A))创建一个和矩阵A有相同规模的矩阵,其中所有元素为0. 阅读全文

posted @ 2013-01-22 16:30 铁树银花 阅读(425) 评论(0) 推荐(0) 编辑

MATLAB描绘饼图——pie

摘要: 一、piepie用于描绘平面饼图。(1)pie(X)利用向量X中的数据描绘饼图。例:X = [1, 1, 2, 2, 3, 4, 5];pie(X)得到注意,X中的数据被看做频数,饼图中比率的获得:X中的元素x[i]/sum(X).当X中所有元素的和sum(X)< 1.0时,图形不是整一个圆。如X = [0.1,0.2,0.3]时,得到2.pie( X, {'...', '...', ...} )X的意义同上,是数据向量,‘...’是标注。例子:X = [2,3,5];pie(X,{'2','3','5'}) 阅读全文

posted @ 2013-01-22 09:39 铁树银花 阅读(1059) 评论(0) 推荐(0) 编辑

2013年1月21日

MATLAB求矩阵的规模——size & length

摘要: 1.size对于M*N矩阵A,size(A)返回两个值,分别为M和N。例:对于矩阵A =[1,2;3,4;2,6],size(A)返回3和2,分别是A的行数和列数。2.length对于M*N矩阵A,length(A)返回M和N中较大者。故而当A是向量时,length(A)就是A的维数。 阅读全文

posted @ 2013-01-21 16:47 铁树银花 阅读(653) 评论(0) 推荐(0) 编辑

2013年1月20日

MATLAB——scatter的简单应用

摘要: scatter可用于描绘散点图。1.scatter(X,Y)X和Y是数据向量,以X中数据为横坐标,以Y中数据位纵坐标描绘散点图,点的形状默认使用圈。例子:X = [1:10];Y = X + rand(size(X));scatter(X, Y)得到:2.scatter(...,'filled')描绘实心点。例:3.scatter3(x,y,z)描绘三维图像。例子: 阅读全文

posted @ 2013-01-20 15:57 铁树银花 阅读(890) 评论(0) 推荐(0) 编辑

MATLAB获取随机数——rand

摘要: rand 可用于获得均匀分布的伪随机数。1.R = rand(N) 返回一个N*N的矩阵,其中的元素是来自(0,1)的随机数。例>> rand(3)ans = 0.8147 0.9134 0.2785 0.9058 0.6324 0.5469 0.1270 0.0975 0.95752.rand(M,N)or rand([M,N])返回一个M-by-N的矩阵,其中的元素是来自于(0,1)的随机数。3.rand(SIZE(A))返回与矩阵A具有相同规模的矩阵,矩阵中元素是来自于(0,1)的随机数。例A = [1,2;2,3];rand(size(A))得到ans = 0.5472 0 阅读全文

posted @ 2013-01-20 15:41 铁树银花 阅读(838) 评论(0) 推荐(0) 编辑

MATLAB矩阵的合成。

摘要: 以下大写字母均表示矩阵。1.C = [A,B]表示将矩阵A和B水平合成为矩阵C。例1:有指令:>> A = [1:3];>> B = [4:5];>> C = [A,B];矩阵A为A = 1 2 3矩阵B为B = 4 5合成C为C = 1 2 3 4 5例2:有指令>> A = [1,2;3,4];>> B = [3,4;5,6];>> C = [A,B];其中A = 1 2 3 4B = 3 4 5 6C = 1 2 3 4 3 4 5 62.C = [A;B]将矩阵A和B垂直合成为矩阵C例1:>> A = 阅读全文

posted @ 2013-01-20 12:02 铁树银花 阅读(716) 评论(0) 推荐(0) 编辑

MATLAB产生连续均匀分布的随机数组——unifrnd

摘要: unifrnd可以创建随机的连续均匀分布的数组。1.R = unifrnd(A,B)returns an array of random numbers chosen from the continuous uniform distribution on the interval from A to B. The size of R is the common size of A and B if both are arrays. If either parameter is a scalar, the size of R is the size of the otherparameter.这 阅读全文

posted @ 2013-01-20 11:37 铁树银花 阅读(2698) 评论(0) 推荐(0) 编辑

MATLAB实现频数表——hist的使用

摘要: 借助命令hist,matlab可以通过两个方式实现频数表。1.[f, xout] = hist(X)将数据向量X的取值范围均分为10个区间,统计频数,返回频数向量f和区间中点行向量xout.例1.执行指令>> X = [1, 1.2, 1.3, 2, 3, 3.2, 3.5, 4, 4.5, 5, 6];>> [f, xout] = hist(X)得到f = 3 1 0 1 2 1 1 1 0 1xout = 1.2500 1.7500 2.2500 2.7500 3.2500 3.7500 4.2500 4.7500 5.2500 5.75002.[f, xout] 阅读全文

posted @ 2013-01-20 10:23 铁树银花 阅读(3571) 评论(0) 推荐(0) 编辑

MATLAB实现频数直方图——hist的使用

摘要: "hist" is short for "Histogram(直方图、柱状图)"。1.N = hist(Y)bins the elements of Y into 10 equally spaced containersand returns the number of elements in each container. If Y is a matrix, hist works down the columns.(将向量Y的元素平均分到十个等间隔的容器中,并且返回每个容器的元素个数。如果Y是一个矩阵,hist指令逐列元素操作。Y为向量的情形见例1和2 阅读全文

posted @ 2013-01-20 10:14 铁树银花 阅读(5812) 评论(0) 推荐(0) 编辑

MATLAB——linspace

摘要: linspace用于产生等差数列。1.linspace(x, y)产生一个有100个元素的行向量,其中的元素在区间[x, y]中等间隔分布。如linspace(1,10)产生:Columns 1 through 9 1.0000 1.0909 1.1818 1.2727 1.3636 1.4545 1.5455 1.6364 1.7273 Columns 10 through 18 1.8182 1.9091 2.0000 2.0909 2.1818 2.2727 2.3636 2.4545 2.5455 Columns 19 through 27 2.6364 2.7273 2.8182 2 阅读全文

posted @ 2013-01-20 08:55 铁树银花 阅读(1211) 评论(0) 推荐(0) 编辑

2013年1月18日

MATLAB——polyfit

摘要: matlab的polyfit命令,可以理解为“polynomial fitting”,用于数据的多项式拟合。常用的几种命令格式:1.P = POLYFIT(X,Y,N)功能:在最小二乘法意义之上,求解Y关于X的最佳的N次多项式函数。返回值P为N+1维参数向量p(1),p(2)....所得的多项式为P(1)*X^N + P(2)*X^(N-1) +...+ P(N)*X + P(N+1)2.[P,S] = POLYFIT(X,Y,N)功能:(1)P的意义同1,是参数矩阵。S是规模为1×1的结构数组,包括R(系数矩阵的QR分解的上三角阵),df(自由度),normr(拟合误差平方和的算术 阅读全文

posted @ 2013-01-18 11:48 铁树银花 阅读(8419) 评论(0) 推荐(0) 编辑

MATLAB——axis

摘要: axis中文为“轴”之意,在matlab中用于控制坐标轴的范围和样式(颜色等)。axis([XMIN XMAX YMIN YMAX]) 设置当前所绘图像的x轴和y轴的范围。axis([XMIN XMAX YMIN YMAX ZMIN ZMAX]) 设置当前所绘图像的x轴、y轴和z轴的范围。例子:>> x = [1,2,3,4,5];>> y = [2,3,4,5,6];>> plot(x,y,'o')>> axis([0,5,0,6]);得到图像 阅读全文

posted @ 2013-01-18 11:16 铁树银花 阅读(854) 评论(0) 推荐(0) 编辑

2013年1月17日

MATLAB——PLOT绘图

摘要: 格式化绘图: 1.color:bg rcmy k wblue green red cyanmagentayellowblack white2.type of coordinate point.o x+ *sd v^ <>phpoint circle x-mark plusstar squarediamondtriangle (down)triangle (up)triangle (left)riangle (right)pentagram(五角星形)hexagram(六角星形)3.type of line- :-. -- (none) soliddotteddashdotdashe 阅读全文

posted @ 2013-01-17 10:56 铁树银花 阅读(293) 评论(0) 推荐(0) 编辑

2013年1月16日

(Your)((Term)((Project)))(字符串处理)

摘要: (Your)((Term)((Project)))Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 2709Accepted: 1010DescriptionYou have typed the report of your term project in your personal computer. There are several one line arithmetic expressions in your report. There is no redundant parentheses in the expressi 阅读全文

posted @ 2013-01-16 23:15 铁树银花 阅读(220) 评论(0) 推荐(0) 编辑

2013年1月12日

Rails(poj 1363 栈的应用)

摘要: RailsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 19760Accepted: 7957DescriptionThere is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish 阅读全文

posted @ 2013-01-12 21:23 铁树银花 阅读(209) 评论(0) 推荐(0) 编辑

gets()

摘要: 参考资料:点击打开链接原型:char * gets ( char * str );功能:通过标准输入(stdin)读入字符并存储到C类型的字符串,当检测到换行符或者文件结束符时停止读入。换行符和文件结束符不读入字符串中。'\0'自动添加到字符串的最后。参数str:str是指向一段内存空间的指针或者是字符数组的数组名,它指向所读入的字符串,注意str指向的内存空间中原有的内容将被修改。返回值:(1)读入成功:返回str。(2)读入失败:返回NULL。例程:/* gets example */ #include <stdio.h> int main() { char s 阅读全文

posted @ 2013-01-12 15:31 铁树银花 阅读(249) 评论(0) 推荐(0) 编辑

Matrix Chain Multiplication(栈的简单应用)

摘要: Matrix Chain MultiplicationTime Limit: 2 Seconds Memory Limit: 65536 KBMatrix multiplication problem is a typical example of dynamical programming.Suppose you have to evaluate an expression like A*B*C*D*E where A,B,C,D and E arematrices. Since matrix multiplication is associative, the order in whi.. 阅读全文

posted @ 2013-01-12 11:57 铁树银花 阅读(415) 评论(0) 推荐(0) 编辑

2013年1月11日

Sockets

摘要: 原题链接:点击打开链接A. Socketstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets.Overall Vasya has got m d 阅读全文

posted @ 2013-01-11 19:55 铁树银花 阅读(486) 评论(0) 推荐(0) 编辑

2013年1月8日

vc6.0执行程序正确而debug版和release版运行错误

摘要: 使用vc6.0直接执行程序和执行debug版本或release版本的程序在执行环境上有差异。vc6中调试运行时,默认的当前目录是工程.dsw文件所在的目录,而debug版或release版直接运行时,当前目录是exe所在的目录。比如有文件1.txt在dsw文件所在目录下而不在exe文件所在目录下,则用vc直接运行程序时能打开1.txt,但直接运行exe文件时打开失败。 阅读全文

posted @ 2013-01-08 20:49 铁树银花 阅读(224) 评论(0) 推荐(0) 编辑

visio调整画布大小和旋转画布

摘要: 1.调整画布大小:鼠标移至画布边界(注意不能是顶点附近),按下ctrl,就会出现双向箭头,拖动鼠标即能调整画布大小。2.旋转画布:鼠标移至画布顶点或附近,按下ctrl, 出现单箭头优弧,移动鼠标即能旋转画布。也可先按住ctrl,再移动鼠标~仅供参考^_^2013-1-08 阅读全文

posted @ 2013-01-08 13:56 铁树银花 阅读(4013) 评论(0) 推荐(0) 编辑

2012年12月19日

convert 'std::vector<>::iterator {aka __gnu_cxx::__normal_iterator<*, std::vector<> >}' to '*' in in

摘要: 错误程序:#include <iostream> #include <vector> using namespace std; struct A { int x; A(int y) {x = y;} }; int main() { A a(11217); vector<A> V; V.push_back(a); vector<A>::iterator it = V.begin(); A *p = it; return 0; }编译报错:error: cannot convert 'std::vector<A>::iterat. 阅读全文

posted @ 2012-12-19 18:47 铁树银花 阅读(1776) 评论(0) 推荐(0) 编辑

error: creating array of references( declaration of 'a' as array)

摘要: 错误程序:#include <iostream> using namespace std; void func(int& a[], int n) { for(int i = 0; i < n; i++) a[i]++; } int main() { int a[3] = {1, 2, 3}; func(a, 3); cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl; return 0; } 初衷:通过建立引用型形参 阅读全文

posted @ 2012-12-19 17:02 铁树银花 阅读(329) 评论(0) 推荐(0) 编辑

导航