![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
递归
BYSora
这个作者很懒,什么都没留下…
展开
-
Lightoj1006——Hex-a-bonacci(递归转递推)
Given a code (not optimized), and necessary inputs, you have to find the output of the code for the inputs. The code is as follows:int a, b, c, d, e, f; int fn( int n ) { if( n == 0 ) return a;原创 2016-04-13 17:53:36 · 1047 阅读 · 0 评论 -
山东省第五届ACM省赛题——Circle(递推求概率)
题目描述 You have been given a circle from 0 to n - 1. If you are currently at x, you will move to (x - 1) mod n or (x + 1) mod n with equal probability. Now we want to know the expected number of steps y原创 2016-04-26 20:44:53 · 1091 阅读 · 1 评论 -
poj2506——Tiling(递推+大数加)
DescriptionIn how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tiling of a 2x17 rectangle. InputInput is a sequence of lines, each line containing an integer number原创 2016-12-12 20:52:15 · 842 阅读 · 0 评论 -
poj2299——Ultra-QuickSort(归并排序)
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 sequence i原创 2017-01-19 20:29:24 · 755 阅读 · 0 评论 -
蓝桥杯算法训练——未名湖边的烦恼 (递归)
问题描述 每年冬天,北大未名湖上都是滑冰的好地方。北大体育组准备了许多冰鞋,可是人太多了,每天下午收工后,常常一双冰鞋都不剩。 每天早上,租鞋窗口都会排起长龙,假设有还鞋的m个,有需要租鞋的n个。现在的问题是,这些人有多少种排法,可以避免出现体育组没有冰鞋可租的尴尬场面。(两个同样需求的人(比如都是租鞋或都是还鞋)交换位置是同一种排法) 输入格式 两个整数,表示m和n 输出格式原创 2017-03-01 12:36:10 · 814 阅读 · 0 评论 -
蓝桥杯算法训练——2的次幂表示 (递归)
问题描述 任何一个正整数都可以用2进制表示,例如:137的2进制表示为10001001。 将这种2进制表示写成2的次幂的和的形式,令次幂高的排在前面,可得到如下表达式:137=2^7+2^3+2^0 现在约定幂次用括号来表示,即a^b表示为a(b) 此时,137可表示为:2(7)+2(3)+2(0) 进一步:7=2^2+2+2^0 (2^1用2表示) 3=2+2^原创 2017-03-01 14:42:03 · 800 阅读 · 0 评论 -
poj1942——Paths on a Grid(求阶乘)
DescriptionImagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered years ago (this time he’s explaining that (a+b)2=a原创 2017-03-01 20:47:06 · 909 阅读 · 0 评论 -
poj1664——放苹果(递推)
Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 Input第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数M和N,以空格分开。1<=M,N<=10。 Output对输入的每组数据M和N,用一行输出相应的K。 Sample Input1 7 3 Sampl原创 2017-05-03 15:02:26 · 1658 阅读 · 0 评论