块大小为10^5。#includeusing namespace std;const int table[] = {0, 4784, 8978, 12981, 16901, 20732, 24523, 28249, 31916, 35585, 39176, 42818, 46430, 49962, ...
分类:
其他好文 时间:
2015-07-12 18:39:45
阅读次数:
433
矩阵树定理求生成树计数模板.
原题是SPOJhighways
代码又长又丑…#include
#include
#include
#include
#include
#define MAXN 20
#define eps 1e-9
using namespace std;
int A[MAXN][MAXN]...
分类:
其他好文 时间:
2015-07-12 17:29:52
阅读次数:
136
该题的思路很简单,就是对BST进行先序遍历,找到第k个数的时候返回。这里借助栈用迭代实现,递归的代码更简单,没有尝试。
class Solution {
public:
int kthSmallest(TreeNode* root, int k) {
stack cache;
TreeNode *point = root;
TreeNode...
分类:
其他好文 时间:
2015-07-12 17:27:38
阅读次数:
85
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
class Point{
int x;
int y;
public Point(){
x = 1;
y = 2;
}
public void setX(int x) {
this.x = x;
}
public voi...
分类:
编程语言 时间:
2015-07-12 17:27:06
阅读次数:
105
思路: 利用二分查找,分别查找待统计数字的头和尾的下标,最后做差加一即为结果。C++: 1 #include 2 #include 3 using namespace std; 4 5 int GetFirstK(vector& nums, int startpos, int endpos,...
分类:
编程语言 时间:
2015-07-12 17:24:20
阅读次数:
146
用函数指针把这个确定的地址转化成一个函数指针这就明白了程序中调用函数的意义测试代码如下: 1 #include 2 3 void getMemory() 4 { 5 printf("i am here!"); 6 } 7 8 void main() 9 {10 int *p;1...
分类:
其他好文 时间:
2015-07-12 17:22:52
阅读次数:
131
Given an integer, write a function to determine if it is a power of two.判断一个数是不是2的幂。思路,找出该数中二进制位1的个数 public boolean isPowerOfTwo(int n) { if...
分类:
其他好文 时间:
2015-07-12 17:10:52
阅读次数:
85
https://leetcode.com/problems/climbing-stairs/ 1 class Solution { 2 public: 3 int climbStairs(int n) { 4 if(n==1) 5 return 1; ...
分类:
其他好文 时间:
2015-07-12 17:09:48
阅读次数:
107
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x...
分类:
其他好文 时间:
2015-07-12 17:09:37
阅读次数:
95
/* 检测平衡符号 */#include#includestruct stack;typedef struct stack * PtrToStack;struct stack{ char *Array; int TopOfStack; int Capacity;};PtrToSta...
分类:
其他好文 时间:
2015-07-12 17:05:33
阅读次数:
181