自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 收藏
  • 关注

原创 leetcode Jump Game II

ven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is

2014-07-06 19:11:43 456

原创 leetcode Gas Station

There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to

2014-05-30 10:42:59 423

原创 leetcode candy

There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on

2014-05-29 23:41:41 514

原创 leetcode Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.题目大意:对一个单向链表进行深度拷贝,单向链表的每个结点还有

2014-05-06 19:45:56 408

原创 leetcode WordBreak II

题目大意 给定一个单词集合一个z

2014-05-06 11:41:54 430

原创 leetcode wordBreak

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"

2014-04-28 16:48:50 389

原创 leetcode Linked List Circle

首先要判断一个链表是否是循环的

2014-04-27 20:20:32 782

原创 二叉树的基本遍历算法

基本数据结构struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};houxu

2014-04-17 10:59:00 571

原创 leetcode LRU Cache

题目大意就是实现一个使用最近最少shiyon

2014-04-13 17:04:36 581

原创 leetcode Evaluate Reverse Polish Notation

逆波兰式的求解,主要注意的问题就是,输入的是string数组,需

2014-04-13 11:31:24 373

原创 leetcode Max Points on a Line

#include #include #include using namespace std;//自定义的分数 a表示分数 b表示分母class Key{public: int a, b; Key(): a(0), b(0){} Key(int x, int y) : a(x), b(y){} friend bool operator < (co

2014-04-12 20:26:02 441

原创 leetcode Reorder List

#include using namespace std;/** * Definition for singly-linked list.*/ struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; void print(L

2014-04-12 20:16:14 325

原创 leetcode Insertion Sort List

题目大意:实现链表的插入排序算法/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution { pu

2014-04-12 00:17:55 351

原创 C++ 代理类的实现

#include #include class Vehicle{protected: std::string name;public: Vehicle():name("noName"){}; Vehicle(const std::string& s):name(s){}; virtual Vehicle * clone() const = 0; v

2014-04-11 17:24:06 649

原创 常见的几种排序算法

#include #include using namespace std;class Solution {public: //两端向中间靠拢 int partition1(vector &array, int left, int right) { int pivot = array[left]; int p = left;

2014-04-11 16:02:00 324

原创 leetcode Sort List

题目的主要大意是对lianbiao/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {publi

2014-04-11 11:13:34 411

原创 poj 2109 高精度幂和二分查找

c.s.push_back((char)(bit % 10 + '0')); add = bit / 10; i++; } while(i < sizeB) { bit = b.s[i] - '0' + add; c.s.push_back((char)(bit % 10 + '0')); ad

2014-04-10 13:06:39 462

原创 排列的基本算法

#include using namespace std;//判断是否有上一个排列,判断依据为ai < ai-1bool has_prev_permute(int a[], int n){ for(int i = n - 1; i >= 1; i--) if(a[i - 1] > a[i] ) return true; ret

2014-04-06 16:17:42 491

原创 poj 1901 跳蚤 扩展欧几里得定理和容斥原理的应用

跳蚤Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7841 Accepted: 2275DescriptionZ城市居住着很多只跳蚤。在Z城市周六生活频道有一个娱乐节目。一只跳蚤将被请上一个高空钢丝的正中央。钢丝很长,可以看作是无限长。节目主持人会给

2014-03-24 23:21:14 783

原创 poj 1601 青蛙的约会 扩展欧几里得定理应用

青蛙的约会Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 86204 Accepted: 15142Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止

2014-03-24 00:13:57 853

原创 poj 1062 昂贵的聘礼 Dijkstra 算法应用

昂贵的聘礼Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 34309 Accepted: 9812Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他

2014-03-22 21:13:27 520

原创 poj 1062 昂贵的聘礼 DFS算法应用

昂贵的聘礼Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 34297 Accepted: 9811Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁

2014-03-22 15:54:14 489

原创 poj 1017 Packets 模拟题

PacketsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 41736 Accepted: 14018DescriptionA factory produces products packed in square packets of the sam

2014-03-22 01:09:26 474

原创 poj 1019 Number Sequence 对数的分解应用

Number SequenceTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 32773 Accepted: 9360DescriptionA single positive integer i is given. Write a program to

2014-03-21 16:29:06 601

原创 poj 1016 Numbers That Count 字符串操作

Numbers That CountTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 18359 Accepted: 6104Description"Kronecker's Knumbers" is a little company that manuf

2014-03-20 23:08:15 518

原创 poj 1989 The Cow Lineup 最短非子序列问题

本题的关键是发现最短非子序列和长度为n的序列之间的关系,规律是在长度为n的排列中找出囊括1到k的排列的个数 num,那么长度为num的序列都是长度为n的子序列,因为都可以从num囊括1到k的排列中挑选出符合要求的数字组成长度为num的序列 然后最短非子序列的长度为num + 1如题中所给示例  1 5 3 2 5 1 3 4 4 2 5 1 2 3         (1 5 3 2 5 1

2014-03-20 18:48:20 1271

原创 poj 1975 Median Weight Bead 传递闭包的应用

本题大意:有n(n为奇数 ) 个珠子,分别标记为 1到 n,在每个例子中将会读入数据 i j 表示 i 比 j 重 ,题目要求从读入的 i j 关系 中判断有多少个 不可能是这些珠子重量的中位数。n的上限为99,本题主要利用的是传递闭包的算法,利用传递闭包找出现有的i j 之间的关系#include #define N 100bool closure[N][N]; //如果closure

2014-03-20 15:41:47 536

原创 poj 1962 Corporative Network 并查集的应用

题目大意:给定n个结点 ,初始时每个结点到中心结点的距离为0,  E I 表示查询 I结点到中心结点的距离,I  I  J 表示将J的中心结点设为I的中心结点。 I结点到J结点的距离为abs(I - J)mod 1000。 #include #define N 20001int f[N], dis[N];int Abs(int x){ return x >= 0 ? x : -

2014-03-19 23:58:56 619

原创 poj 1926 Pollution 并查集解决污染计算问题

#include #define N 101int f[N];double p[N];//记录顶点污染指数int con[N]; //记录连通数int rank[N]; int total[N];//记录该集合总的连通数量int Find(int x){ if(x != f[x]) { f[x] = Find(f[x]); } return f[x];}void

2014-03-18 22:42:10 528

转载 poj 1742 多重背包算法优化问题

CoinsTime Limit: 3000MS Memory Limit: 30000KTotal Submissions: 26971 Accepted: 9152DescriptionPeople in Silverland use coins.They have coins of value A1,A2,A3

2014-03-18 00:23:27 716

空空如也

空空如也

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

TA关注的人

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