自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 HDU 3485 Count 101

Problem DescriptionYou know YaoYao is fond of his chains. He has a lot of chains and each chain has n diamonds on it. There are two kinds of diamonds, labeled 0 and 1. We can write down the label of

2015-06-19 18:40:20 571

原创 HDU 3506 Monkey Party

Far away from our world, there is a banana forest. And many lovely monkeys live there. One day, SDH(Song Da Hou), who is the king of banana forest, decides to hold a big party to celebrate Crazy Banan

2015-06-19 17:58:46 646

原创 POJ 1083 Moving Tables

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the

2015-06-19 16:14:29 637

原创 Eclipse配色方案插件

最近发现了一个Eclipse配色方案插件,这回给Eclipse配色太方便了。插件主页:http://eclipsecolorthemes.org/插件提供了上万种配色方案,非常漂亮,上图看下:安装很简单,打开 Eclipse Marketplace查找 Eclipse Color Theme,会找到这个插件。安装完成后进入 Pre

2015-06-19 12:17:47 462

原创 CF 551D GukiZ and Binary Operations

We all know that GukiZ often plays with arrays. Now he is thinking about this problem: how many arrays a, of length n, with non-negative elementsstrictly less then 2l meet the following condit

2015-06-18 22:14:58 697

原创 551C GukiZ hates Boxes

Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way.In total there are n piles of boxes, arranged in a line, from left to right,i-th

2015-06-18 21:13:39 715

原创 551B ZgukistringZ

Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.GukiZ has strings a, b, and c. He wants to obtain stringk by swapping some letters

2015-06-18 17:29:35 1090

转载 经典位操作

最近看了一篇文章>感觉不错,适当的做一下笔记。原文地址:http://graphics.stanford.edu/~seander/bithacks.html#OperationCounting1、Compute the sign of an integer // we want to find the sign of v int v; // the re

2015-06-18 09:45:37 981

转载 Detect if two integers have opposite signs

来源: http://www.geeksforgeeks.org/detect-if-two-integers-have-opposite-signs/不采用算术运算符,我们可以采用以下几种方法。(1) 首先异或操作可以判断两个数是否是同号的,因为异或运算是将符号位包括在内的,非负数符号位为0,负数符号位为1,所以0^1=1,异或的结果符号位1,即为负数。#includ

2015-06-17 23:14:59 498

转载 Find the element that appears once

来源:http://www.geeksforgeeks.org/find-the-element-that-appears-once/问题:在一个数组中,其中有一个元素只出现一次,其余元素都出现三次,如何在O(n)的时间复杂度和O(1)的复杂度内找到那个元素。首先我的想法是,一个数如果出现了三次,则这个数的二进制对应的位上1的个数肯定为3.这样我们可以枚举每一位,计算所有数

2015-06-17 22:17:28 421

原创 Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0

2015-06-17 21:27:26 469

原创 Best Time to Buy and Sell Stock IV

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may no

2015-06-17 20:58:10 542

原创 Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2015-06-17 20:44:38 382

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total numb

2015-06-17 19:40:15 419

原创 House Robber II

After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a ci

2015-06-17 19:26:43 375

原创 Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return

2015-06-17 11:24:16 359

原创 Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st

2015-06-17 10:21:50 499

原创 Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr

2015-06-16 23:14:17 517

原创 Wildcard Matching

Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t

2015-06-15 23:28:30 405

原创 Word Break

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"

2015-06-15 21:59:48 401

原创 The Skyline Problem

A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as

2015-06-15 21:43:52 561

原创 Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.解题思路:每次选出最小的元素,添加到我们的链表尾部即可,总的时间复杂度为O(K*N)./** * Definition for singly-linked list. * struct

2015-06-15 18:13:02 362

原创 Dungeon Game

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially p

2015-06-15 15:17:11 365

原创 Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).解题思路:其实本题的核心便是在O(log(

2015-06-15 08:41:19 482

原创 Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non

2015-06-14 10:31:33 509

原创 Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2015-06-14 09:51:07 288

原创 Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret

2015-06-14 09:40:15 338

原创 Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",

2015-06-13 22:38:46 352

原创 Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN

2015-06-13 21:31:55 385

原创 Best Time to Buy and Sell Stock III

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You

2015-06-13 21:31:12 435

原创 First Missing Positive

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant

2015-06-13 12:01:20 284

原创 Search in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur

2015-06-13 11:11:58 316

原创 leetcode Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]

2015-06-13 10:24:39 427

原创 1402 最大值

一个N长的数组s[](注意这里的数组初始下标设为1,而不是0,即N个元素为s[1],s[2],...,s[N]),满足以下性质:1)每个元素都是非负的整数,且s[1]=0;2)任意两个相邻元素差值的绝对值不大于1,即| s[i]-s[i+1] |3)对于部分特殊点xi,要求s[xi]问在以上约束下s[]中的最大值最大可能是多少?Input多组测试数据,第

2015-06-12 21:53:53 590

原创 三次方格取数

多线程DP。#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;/* 多线程的dp:按照对角线来

2015-06-12 20:34:07 372

原创 455A Boredom

简单DP。#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;const int maxn = 10001

2015-06-12 11:18:52 414

原创 461A - Appleman and Toastman

简单贪心。#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;const int maxn = 10010

2015-06-11 21:36:54 303

原创 1276 岛屿的数量

有N个岛连在一起形成了一个大的岛屿,如果海平面上升超过某些岛的高度时,则这个岛会被淹没。原本的大岛屿则会分为多个小岛屿,如果海平面一直上升,则所有岛都会被淹没在水下。给出N个岛的高度。然后有Q个查询,每个查询给出一个海平面的高度H,问当海平面高度达到H时,海上共有多少个岛屿。例如:岛屿的高度为:{2, 1, 3, 2, 3}, 查询为:{0, 1, 3, 2}。当海面高度为0时,所有的

2015-06-11 20:45:42 549

原创 1246 罐子和硬币

有n个罐子,有k个硬币,每个罐子可以容纳任意数量的硬币。罐子是不透明的,你可以把这k个硬币任意分配到罐子里。然后罐子被打乱顺序,你从外表无法区别罐子。最后罐子被编上号1-n。每次你可以询问某个罐子,如果该罐子里有硬币,则你可以得到1个(但你不知道该罐子中还有多少硬币),如果该罐子是空的,你得不到任何硬币,但会消耗1次询问的机会。你最终要得到至少c枚硬币(c 例如:有3个罐子,10个硬币

2015-06-09 19:14:46 758

原创 1163 最高的奖励

有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励。在结束时间之前完成该任务,就可以获得对应的奖励。完成每一个任务所需的时间都是1个单位时间。有时候完成所有任务是不可能的,因为时间上可能会有冲突,这需要你来取舍。求能够获得的最高奖励。Input第1行:一个数N,表示任务的数量(2 <= N <= 50000)第2 - N + 1行,每行2个数,中间用空格分隔,表

2015-06-09 17:53:31 711

空空如也

空空如也

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

TA关注的人

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