1. 非递归实现int max_common_divisor(int a, int b){ int nRet=1; int max=a>b?b:a; for(int i=min; i>2; i++) { if(a%i==0 && b%i==0) nRet=i; } return n...
分类:
其他好文 时间:
2015-04-18 17:17:45
阅读次数:
94
常用数据结构及算法C#实现1.冒泡排序、选择排序、插入排序(三种简单非递归排序) 1 int[] waitSort = { 1,0, 12, 13, 14, 5, 6, 7, 8, 9, 10 }; 2 3 //冒泡排序 4 ...
分类:
编程语言 时间:
2015-04-18 01:02:57
阅读次数:
225
Shoot the BulletTime Limit:2 Seconds Memory Limit:32768 KB Special JudgeGensokyois a world which exists quietly beside ours, separated by a mystical b...
分类:
编程语言 时间:
2015-04-17 01:00:00
阅读次数:
192
啊,是否疲倦了现在的线段树太弱,还递归!那我们就欢乐的学习另外一种神奇的线段树吧!(雾他叫做zkw线段树这个数据结构灰常好写(虽然线段树本身也特别好写……)速度快(貌似只在单点更新方面比线段树快……)是一种自底向上非递归版本的线段树!首先我们来看一个ppt,《统计的力量》这个是发明人的PPT(啊,p...
分类:
其他好文 时间:
2015-04-15 23:16:23
阅读次数:
609
题意:给你一个序列 ,让你求这个序列组成哈夫曼树的 WPL解题思路:优先队列直接搞。因为数太大,用了非递归求解。解题代码: 1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 // File Name: c.cpp 3 // Aut...
分类:
其他好文 时间:
2015-04-15 00:47:57
阅读次数:
178
publicstaticintFoo(inti){if(i<3){return1;}else{returnFoo(i-1)+Foo(i-2);}}staticvoidMain(string[]args){Console.WriteLine(Foo(8));}
常见题了,分治思想,有一个结论划分后,将序列划分为更小的子集,继续应用该结论。图简单,直接递归了,之前看过非递归的写法。。。忘了Impl: 1 #include 2 #include 3 4 using namespace std; 5 6 void postOrder(string str...
分类:
其他好文 时间:
2015-04-13 12:26:41
阅读次数:
255
int func(int n){ if (n ==0) return 0; if (n == 1) return 1; int p = 0; int q = 1; for (int i = 1; i < n; i++){ int...
分类:
其他好文 时间:
2015-04-12 22:37:36
阅读次数:
171