码迷,mamicode.com
首页 >  
搜索关键字:int    ( 143001个结果
【分块打表】bzoj3798 特殊的质数
块大小为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
Kth Smallest Element in a BST
该题的思路很简单,就是对BST进行先序遍历,找到第k个数的时候返回。这里借助栈用迭代实现,递归的代码更简单,没有尝试。 class Solution { public: int kthSmallest(TreeNode* root, int k) { stack cache; TreeNode *point = root; TreeNode...
分类:其他好文   时间:2015-07-12 17:27:38    阅读次数:85
Java 反射常用方法示例
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
【剑指offer 面试题38】数字在排序数组中出现的次数
思路: 利用二分查找,分别查找待统计数字的头和尾的下标,最后做差加一即为结果。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
程序跳转到访问一个确定的地址0x100000
用函数指针把这个确定的地址转化成一个函数指针这就明白了程序中调用函数的意义测试代码如下: 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
[LeetCode] Power of Two
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
Climbing Stairs
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
Lowest Common Ancestor of a Binary Search Tree有问题
/** * 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
习题3.18 检测平衡符号(/* */ 不知怎么做)
/* 检测平衡符号 */#include#includestruct stack;typedef struct stack * PtrToStack;struct stack{ char *Array; int TopOfStack; int Capacity;};PtrToSta...
分类:其他好文   时间:2015-07-12 17:05:33    阅读次数:181
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!