- 博客(10)
- 收藏
- 关注
原创 Leetcode Problem 汇总二
第一题:题目:Jump Game II地址:http://oj.leetcode.com/problems/jump-game-ii/分析:O(n)就可以。DP问题。代码:(Python版)class Solution: # @param A, a list of integers # @return an integer def jum
2014-03-24 17:55:18 1120
原创 Unusual Product
Little Chris is a huge fan of linear algebra. This time he has been given a homework about theunusual square of a square matrix.The dot product of two integer number vectorsx and y of sizen is
2014-03-23 09:18:22 471
原创 寻找最大数
寻找最大数时间限制:1000 ms | 内存限制:65535 KB难度:2描述 请在整数 n 中删除m个数字, 使得余下的数字按原次序组成的新数最大,比如当n=92081346718538,m=10时,则新的最大数是9888 输入第一行输入一个正整数T,表示有T组测试数据每组测试数据占一行,每行有两个数n,m(n可能是一个很大的整数,但其位数不超过100位,
2014-03-21 22:47:16 425
原创 Leetcode Problem 汇总一
此文章内的所有题目选自Leetcode,实现语言为Python.第一题:Triange地址:http://oj.leetcode.com/problems/triangle/分析:题目要求O(n)的内存,简单DP问题,自下而上。代码:class Solution: # @param triangle, a list of lists of integers
2014-03-15 09:09:36 1123
原创 PI的求法
1671年(J.Gregory)π/4=1-1/3+1/5-1/7+1/9-1/11+....#include #include #include int main(){ double pi = 0.0; int flag, i; int n; while(~scanf("%d", &n)) { pi = 1.0;
2014-03-14 22:30:48 973 1
原创 树状数组专项
poj 2352此题一开始理解错了一个地方,而且一开始也没很好的理解树状数组,做了很长时间。其实此题的输入是有规律的,即一直按照x,y递增的规律。所以,判断第i个输入,只需要判断前i-1个元素中x的值,而不用考虑y,因为y一直是递增输入的。所以用一个树状数组来处理x即可。#include #include #include int level[15010];int x
2014-03-10 23:02:24 654
原创 poj 3481 AVL 平衡二叉树
平衡二叉树的简单应用:#include #include typedef struct node{ int k, p; struct node *next, *prior;}AVL;AVL *head, *last;AVL *creat(){ AVL *s; s = (AVL *)malloc(sizeof(AVL)); s->next
2014-03-08 23:43:09 1135
原创 平衡树 balanced binary tree (AVL tree)
平衡二叉树(Balanced binary tree)是由阿德尔森-维尔斯和兰迪斯(Adelson-Velskii and Landis)于1962年首先提出的,所以又称为AVL树。定义:平衡二叉树或为空树,或为如下性质的二叉排序树: (1)左右子树深度之差的绝对值不超过1; (2)左右子树仍然为平衡二叉树. 平衡因子BF=左子树深度-右子树深度.
2014-03-05 22:17:09 768
原创 寻找n个数中k个数的最小公倍数
给定一个数组,其中含有n个整数,还给定一个整数X,可以从n个数中选取任意个数的元素,使这些元素的最小公倍数为X,如果存在则返回Possible,否则返回Impossible.#include #include #include #include #include #include #include #include #include #include #includ
2014-03-05 12:40:47 984
原创 二叉堆 hdu 4006
C# include # include # include # define INF 1000000int heap[1000010];int arr[1000010];int k,n;int cmp(const void *a,const void *b){return *(int *)a - *(int *)b;}void update(int val){ i
2014-03-03 23:04:17 628
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人