自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Heu_Ice_Fire的专栏

走在学习编程的路上……

  • 博客(135)
  • 收藏
  • 关注

原创 LeetCode 解题

LeetCode上的题目都是面试中常遇到的,涉及到一些很基础

2014-05-31 10:06:42 623

原创 hdu dp46题代码

hdu 1864最大报销额解法: 01背包问题,dfs也可以。#include#include#includedouble dp[35],ans[35];double Q,max;int N,k;int main(){ double sum,price,cc,arr[3]; int i,j,flag,m; char div; whil

2013-11-06 21:12:05 597

原创 hdu dp46题

【原创】转载请说明出处!动态规划:利用问题的最优性原理,以自底向上的方式,从子问题的最优解,逐步构造出整个问题的最优解。                                1.HDOJ 1864 最大报销额                                0 1 背包,范围内的最大值                         i从0到最后递推,每次d

2013-11-03 23:10:16 610

原创 糗事百科爬虫

__author__ = 'think'# -*- coding:utf-8 -*-import urllibimport urllib2import reimport threadimport timeclass QSBK: def __init__(self): self.pageIndex = 1 self.user_agent

2015-03-08 10:31:52 550

原创 Codeforces集锦

Codeforces Round #130 DIV. 2Problem A分析:水题#include #include #include #include #include #include #include #include #include #include #include using namespace std;int main(){ strin

2014-07-08 22:39:57 486

原创 Coderforces集锦

Coderforces Round #130 DIV. 2 Problem A

2014-07-08 22:38:26 777

原创 TopCoder练习

SRM 400 DIV2250pt分析:直接暴力即可。

2014-07-07 17:51:30 630

原创 LeetCode汇总六

第一题:Longest Consecutive Sequence分析:

2014-07-02 23:58:33 432

原创 SGU_submit

#coding=utf-8import urllib, urllib2class acm_sgu_ru(): def __init__(self): self.id = '061902' self.password = ''//此处 self.url = 'http://acm.sgu.ru/sendfile.php?contest=

2014-06-09 12:08:03 434

原创 LeetCode汇总五

第一题:Convert Sorted Array to Binary Search Tree

2014-05-31 15:41:10 665

原创 扩展欧几里得

POJ 2115#include #include #include #include #include #include #define LL long long int using namespace std;//the algorithm of extend gcd//ax + by = GCD(a, b) we will get the x and y//O

2014-05-27 13:48:53 387

原创 BitMask

二进制位的一个问题》

2014-05-23 23:48:19 727

原创 数位DP

hdu 2089#include #include int dp[10][3], bit[10];int work(int x){ int i, j, len, k, ans, flag, last; memset(bit, 0, sizeof(bit)); flag = last = ans = len = 0; k = x; while (x) { bit[++

2014-05-05 00:13:13 384

原创 Warm-Up-Problem

POJ 1753

2014-04-21 17:34:08 395

原创 POJ题目分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:  

2014-04-21 11:21:24 518

原创 活动中心 (三分)

描述A市是一个高度规划的城市,但是科技高端发达的地方,居民们也不能忘记运动和锻炼,因此城市规划局在设计A市的时候也要考虑为居民们建造一个活动中心,方便居住在A市的居民们能随时开展运动,锻炼强健的身心。城市规划局希望活动中心的位置满足以下条件:1. 到所有居住地的总距离最小。2. 为了方便活动中心的资源补给和其他器材的维护,活动中心必须建设在A市的主干道上。为了简化问题,

2014-04-19 22:06:48 931

原创 Manacher’s Algorithm( O(n)最长回文串)

An O(N) Solution (Manacher’s Algorithm):First, we transform the input string, S, to another string T by inserting a special character ‘#’ in between letters. The reason for doing so will be immediat

2014-04-17 19:14:53 768

原创 Leetcode Proble 汇总四

第一题:Permutations

2014-04-16 15:26:08 700

原创 Leetcode各题目的难度以及出现频率分析

LeetCode Question Difficulty Distribution : Sheet1        IDQuestionDiffFreqData StructureAlgorithms    

2014-04-08 17:24:37 1038

原创 LeetCode 汇总三

第一题:Climbing Stairs分析:简单DP, dp[i] = dp[i-1]+dp[i-2]代码:(C++版)

2014-04-05 14:44:07 582

原创 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 644

原创 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 435

原创 寻找最大数

寻找最大数时间限制:1000 ms  |  内存限制:65535 KB难度:2描述 请在整数 n 中删除m个数字, 使得余下的数字按原次序组成的新数最大,比如当n=92081346718538,m=10时,则新的最大数是9888 输入第一行输入一个正整数T,表示有T组测试数据每组测试数据占一行,每行有两个数n,m(n可能是一个很大的整数,但其位数不超过100位,

2014-03-21 22:47:16 412

原创 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 717

原创 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 923 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 641

原创 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 1092

原创 平衡树 balanced binary tree (AVL tree)

平衡二叉树(Balanced binary tree)是由阿德尔森-维尔斯和兰迪斯(Adelson-Velskii and Landis)于1962年首先提出的,所以又称为AVL树。定义:平衡二叉树或为空树,或为如下性质的二叉排序树:  (1)左右子树深度之差的绝对值不超过1;  (2)左右子树仍然为平衡二叉树.      平衡因子BF=左子树深度-右子树深度.

2014-03-05 22:17:09 739

原创 寻找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 944

原创 二叉堆 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 586

原创 hdu 1301

依旧是Prim最小生成树的题目。直接下手写。# include # include # include # define INF 10000000int n;int graph[30][30];char c,ch;int visit[30];int dis[30];void Init(){ int i,j; for(i = 1;i <= 26;i

2014-02-15 19:33:05 378

原创 python中的set()

今天晚上在用python做题的时候,用到了set(),这是一个无序不重复集合。比如 a = [2,2,3,2,3,4]print(set(a))那么,他的结果就是[2,3]集合支持多种操作,比如求交集,差集等等。题目链接:http://codeforces.com/contest/390/problem/An = int(input())a = set()b

2014-02-14 21:32:45 498

原创 hdu 1102 (最小生成树)

此题也是最小生成树,是Prim算法的直接套用,只需要处理一下,对于村庄中已经修好的路,将两村中间的距离设为0即可。然后直接用Prim算法。# include # include # include # define INF 10000000int N,Q;int graph[105][105];int visit[105],dis[105];void Init()

2014-02-14 15:12:17 377

原创 hdu 1233 最小生成树Prim算法

这题是最小生成树的一题目,以前没写过最小生成树,所以在这道题的基础上学习一下最小生成树。这道题中用的到时Prim算法,用的邻接矩阵,所以复杂度是O(V*V)Prim算法的基本思想是:1.清空生成树,任取一个顶点加入生成树2.在那些一个端点在生成树里,另一个端点不在生成树里的边中,选取一条权最小的边,将它和另一个端点加进生成树3.重复步骤2,直到所有的顶点都进入了生成树为止,

2014-02-14 14:39:19 487

原创 并查集题目

在计算机科学中,并查集是一种树型的数据结构,其保持着用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。有一个联合-查找算法(union-find algorithm)定义了两个操作用于此数据结构:Find:确定元素属于哪一个子集。它可以被用来确定两个元素是否属于同一子集。Union:将两个子集合并成同一个集合。并查集的三种基本操作:①、初始化操作void

2014-02-03 15:58:59 456

原创 D. Volcanoes

这道题的思想是 将其线段化,根据相邻线段的区间进行取舍,再就是用到two pointer算法。还没写出来,以后再写,太麻烦了。日后调试之。http://codeforces.com/contest/384/problem/D# include # include # include typedef struct node{ int x,y;}node;typede

2014-01-28 16:00:16 567

原创 HASH函数类题目

hdu 1264这个用不到神马hash,直接暴力就OK了,不过要注意输入的顶点问题,处理一下矩形对角线的顶点。# include # include # include int visit[110][110];int main(){ int a,b,c,d,i,j,sum; int temp; for(i = 0;i < 110;i ++)

2014-01-16 19:38:32 709

原创 丑数(humble number) hdu 1058 DP

A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.

2013-12-28 23:47:48 586

原创 kmp poj 3461

这是一道KMP的水题,还没明白KMP是怎么回事 ==,先贴了代码,明天继续研究。#include #include const int MaxN = 1000010;char word[MaxN/10], txt[MaxN];int next[MaxN/10];void KMP_next(char b[], int pre[]){ int n = (int)st

2013-12-23 23:07:31 563 1

原创 SRM 600 DIV2

250ptThe company Manao Inc. cares for its employees and tries to provide them with as much comfort as possible. One of the services Manao Inc. provides is transportation of employees from N

2013-12-16 17:05:08 864

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除