摘要:原理 http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting python代码实现 http://www.roguebasin.com/index.php?title=Python_shadowcasti
        
阅读全文
 
        
            
            
摘要:#include <iostream> #include <cmath> using namespace std; struct Point { float x; float y; Point(float a, float b) : x(a), y(b) { } }; double Length(P
        
阅读全文
 
        
            
            
摘要:string s是输入字符串, palindrome[i][j]表示s.substr(i, j - i + 1)是否为回文。算法时间复杂度和空间复杂度都为O(n^2)。
        
阅读全文
 
        
            
            
摘要:int lowerBound(int* nums, int numsSize, int target) { //注意left和right的初始值必须是left = 0, right = numsSzie, 因为返回的位置可能是[0,numsSize] int left = 0; int right = numsSize; int mid; while (l...
        
阅读全文
 
        
            
            
摘要:链表数据结构 链表归并排序 基于值交换的链表快速排序 基于节点交换的链表快速排序
        
阅读全文
 
        
            
            
摘要:如何判断一个数是2的幂,主要是要找出2的幂次方的数的特点。我们知道,1个数乘以2就是将该数左移1位,而2的0次幂为1, 所以2的n次幂(就是2的0次幂n次乘以2)就是将1左移n位, 这样我们知道如果一个数n是2的幂,则其只有首位为1,其后若干个0,必然有n & (n - 1)为0。(在求1个数的二进...
        
阅读全文
 
        
            
            
摘要:前面我们谈到了,可用通过异或运算交换两个数,而不需要任何的中间变量。 如下面:void exchange(int&a,int&b){a ^=b;b ^=a;a ^=b;}然而,这里面却存在着一个非常隐蔽的陷阱。通常我们在对数组进行操作的时候,会交换数组中的两个元素,如exchang(&a[i], &...
        
阅读全文
 
        
            
            
摘要:lower_bound当target存在时, 返回它出现的第一个位置,如果不存在,则返回这样一个下标i:在此处插入target后,序列仍然有序。代码如下:int lower_bound(int* nums, int numsSize, int target) { //注意left和right的...
        
阅读全文
 
        
            
            
摘要:原文链接:http://blog.sina.com.cn/s/blog_a53544e0010146nv.html异或运算^。是个很重要的位运算。简单的说:0^0=01^0=11^1=0并且有A^0=A A^A=0并且B^A^A=B 因为B^A^A=B^(A^A)=B^0=B然后可以利用他来交换AB...
        
阅读全文
 
        
            
            
摘要:Factors and FactorialsThe factorial of a numberN(writtenN!) is defined as the product of all the integers from 1 toN. It is often defined recursively ...
        
阅读全文
 
        
            
            
摘要:Word AmalgamationIn millions of newspapers across the United States there is a word game calledJumble. The object of this game is to solve a riddle, b...
        
阅读全文
 
        
            
            
摘要:运行时间和下式成正比:N+N/2+N/3+N/7+N/11+……#include #include using namespace std;int main(int argc, char* argv[]){	int n;	if (argc != 2)	{ printf("usage:bin n\n...
        
阅读全文