- 博客(52)
- 资源 (1)
- 收藏
- 关注
原创 POJ 1463 Strategic game
题目: Strategic game Time Limit: 2000MS Memory Limit: 10000K Total Submissions: 8051 Accepted: 3746 DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he
2016-12-13 21:48:27 321
原创 Leetcode 416. Partition Equal Subset Sum[medium]
题目: Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note: Each of the array ele
2016-12-13 21:42:34 334
原创 Leetcode 264. Ugly Number II[medium]
题目: Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10
2016-11-27 21:54:21 334
原创 363. Max Sum of Rectangle No Larger Than K[hard]
题目: Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k.Example: Given matrix = [ [1, 0, 1], [0, -2, 3] ]
2016-11-27 21:05:43 439
原创 Leetcode 96. Unique Binary Search Trees[medium]
题目: Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s.1 3 3 2 1 \
2016-11-27 19:57:06 243
原创 Leetcode 357. Count Numbers with Unique Digits[medium]
题目: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, ex
2016-11-27 19:40:20 461
原创 NP完全问题的归约-碰撞集(HITTING SET)
原题: 在碰撞集(HITTING SET)问题中,给定一组集合{S1, S2, S3, …, Sn}和预算b,我们希望求一个与所有Si相交且规模不超过b的集合H(H与所有Si相交不为空)。证明: (1)hitting set问题是NP问题 只需要验证H的大小是否不超过b,以及验证H与Si的交不为空。 时间复杂度O(nHS)。 所以,hitting set问题为NP问题。 (2)所有问题可
2016-11-27 11:48:51 4573
原创 Leetcode 321. Create Maximum Number[hard]
题目: Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same a
2016-11-16 23:31:12 292
原创 Leetcode 330. Patching Array[hard]
题目: Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the array.
2016-11-16 17:42:45 267
原创 Leetcode 435. Non-overlapping Intervals[medium]
题目: Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note: You may assume the interval’s end point is always
2016-11-16 16:47:33 310
原创 Leetcode 452. Minimum Number of Arrows to Burst Balloons[medium]
题目: here are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it’s horizontal, y-coor
2016-11-16 15:47:56 394
原创 Leetcode 455. Assign Cookies[easy]
题目: Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a
2016-11-16 15:00:56 660
原创 【数值计算】householder矩阵的QR算法,求特征值
#include <iostream>#include <cstdio>#include <cmath>#include <cstring>#include <cstdlib>#define N 10using namespace std;class MT {public: int x, y; double mt[N][N]; MT() {} MT(int x
2016-11-02 23:41:15 4396
原创 Leetcode 126. Word Ladder II[hard]
题目: Given two words (beginWord and endWord), and a dictionary’s word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:Only one letter can be changed at a time E
2016-10-27 13:23:43 318
原创 Leetcode 153. Find Minimum in Rotated Sorted Array & Leetcode 154. Find Minimum in Rotated Sorted Ar
153题目: 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).Find the minimum element.You may assume no duplicate exists in the arr
2016-10-26 20:32:48 278
原创 Leetcode 289. Game of Life[medium]
题目: According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.”Given a board with m by
2016-10-26 19:50:27 253
原创 Leetcode 365. Water and Jug Problem[medium]
题目: You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these t
2016-10-26 19:01:05 297
原创 【数值计算】幂法与反幂法
幂法求矩阵模最大的特征值及其对应特征向量 注:需要模最大特征值唯一,矩阵各列线性无关// 幂法求特征值// 需要保证各列线性无关#include <iostream>#include <cmath>#include <cstdlib>#include <cstring>#include <iomanip>using namespace std;#define N 5class MT {
2016-10-17 21:49:39 11543 1
原创 OpenGL3环境搭建
目前网上几乎所有的OpenGL环境的搭建都是基于OpenGL2的,涉及到新版OpenGL3的几乎没有。所以我就凭感觉自己瞎搞了一下,最后竟然可以用了~嗨森~ 所以呢,就写一遍文章分享一下经验,也顺便记录一下,备忘~我的电脑使用的是VS2015,所以就以VS2015为例,别的IDE应该也差不多。创建自己的include和lib目录创建自己的include和lib目录,之后会用到。 我的目录如下:
2016-10-17 14:17:46 1898
原创 Leetcode 367. Valid Perfect Square[medium]
题目: Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.Example 1:Input: 16 Returns: Tr
2016-10-14 22:33:41 287
原创 Leetcode 368. Largest Divisible Subset[medium]
题目: Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solutions, r
2016-10-14 22:22:29 254
原创 Leetcode 372. Super Pow[medium]
题目: Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example1:a = 2 b = [3]Result: 8 Example2:a = 2 b =
2016-10-14 17:13:23 301
原创 Leetcode 397. Integer Replacement[medium]
题目: Given a positive integer n and you can do operations as follow:If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minimum number of replacem
2016-10-14 16:49:00 252
原创 Leetcode 400. Nth Digit[easy]
题目: Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …Note: n is positive and will fit within the range of a 32-bit signed integer (n < 231).Example 1:Input: 3O
2016-10-14 16:09:38 210
原创 Leetcode 413. Arithmetic Slices[medium]
题目: A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequenc
2016-10-14 15:36:46 525
原创 康托展开
前一阵人工智能课需要写一个八数码的题,其中用到了康托展开。 但当时是直接使用的公式,并没有仔细阅读具体的原理。 所以,今天整理一下。简介康托展开是全排列到自然数的双射,常用于对全排列的哈希。 康托展开实质是表示的是当前排列在全排列中的位置。公式n个数字排列的康托展开公式: 其中,ai表示第i位数字在当前集合是第ai小的数字。逆过程初始化集合Cn为n个数字的全集,Xn=X。Xi mod (
2016-10-14 14:56:31 297
原创 Leetcode 415. Add Strings[easy]
题目: Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9.
2016-10-14 10:13:46 234
原创 OpenGL Tutorial 2 : The first triangle
教程地址:http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/代码备忘:// Include standard headers#include <stdio.h>#include <stdlib.h>// Include GLEW#include <GL/glew.h>// Inclu
2016-10-14 00:56:13 355
原创 Leetcode 399. Evaluate Division[medium]
题目: Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answ
2016-10-12 22:38:13 285
原创 Leetcode 187. Repeated DNA Sequences[medium]
题目: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.Wri
2016-10-12 20:42:56 257
转载 Apache Maven3入门教程
摘要: Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具。 Maven是Apache的一个项目,官网:http://maven.apache.org/ 本教程以3.0.5的版本Maven是一个采用纯Java编写的开 源项目管理工具。Maven采用了一种被称之为project object model (POM)概念来管理项目,
2016-10-10 23:09:16 323
原创 【并行计算】Circular-Shift Routing in Hypercube
并行计算导论课作业,折腾了一下午,基本搞定了。 但是还有几个问题没有解决:有时候执行会莫名崩溃,在send和receive之间加入sleep后,就很少崩溃,这是为什么?我的i7 4700最多只能跑1000多个进程,进程数过多磁盘,cpu使用率直接爆炸,电脑死机,程序运行崩溃。如何才能提高进程并行数?用的MPI实现的多进程。MPI+VS环境的搭建可以参考这篇转载的文章:http://blog.
2016-10-09 21:24:05 883
转载 【并行计算】用MPI进行分布式内存编程(二)
通过上一篇中,知道了基本的MPI编写并行程序,最后的例子中,让使用0号进程做全局的求和的所有工作,而其他的进程却都不工作,这种方式也许是某种特定情况下的方案,但明显不是最好的方案。举个例子,如果我们让偶数号的进程负责收集求和的工作,情况会怎么样?如下图: 对比之前的图发现,总的工作量与之前的一样,但是发现新方案中0号进程只做了3次接收和3次加法(之前的7次接收和7次加法)
2016-10-09 20:59:47 1890
转载 【并行计算】用MPI进行分布式内存编程(一)
通过上一篇关于并行计算准备部分的介绍,我们知道MPI(Message-Passing-Interface 消息传递接口)实现并行是进程级别的,通过通信在进程之间进行消息传递。MPI并不是一种新的开发语言,它是一个定义了可以被C、C++和Fortran程序调用的函数库。这些函数库里面主要涉及的是两个进程之间通信的函数。MPI可以在Windows和linux环境中都有相应的库,本篇以Windows10
2016-10-09 20:58:03 2538
原创 OpenGL tutorial01
备忘。// Include standard headers#include <stdio.h>#include <stdlib.h>// Include GLEW#include <GL/glew.h>// Include GLFW#include <glfw3.h>GLFWwindow* window;// Include GLM#include <glm/glm.hpp>usin
2016-10-09 01:08:52 331
原创 【资源汇总】OpenGL
计算机图形学要用到,数据库的大项目可能也要用到。OpenGL官方文档:https://www.opengl.org/sdk/docs/man/教程:http://www.opengl-tutorial.org/cn/beginners-tutorials/tutorial-1-opening-a-window/GLFW官方文档:http://www.glfw.org/docs/lates
2016-10-08 23:55:28 376
转载 Apache Maven 入门篇
Apache Maven 入门篇 ( 上 ) 作者:George Ma写这个 maven 的入门篇是因为之前在一个开发者会的动手实验中发现挺多人对于 maven 不是那么了解,所以就有了这个想法。这个入门篇分上下两篇。本文着重动手,用 maven 来构建运行 hellow world 程序,体会一下不用任何 IDE ,只用 maven 是咋回事。然后下篇就讲解一下 maven 的核
2016-10-08 00:02:33 212
原创 Leetcode 124. Binary Tree Maximum Path Sum[hard]
题目: Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The
2016-10-07 23:32:47 242
原创 Leetcode 329. Longest Increasing Path in a Matrix[hard]
题目: Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside
2016-10-07 22:42:06 245
原创 MySQL环境搭建及SQL查询语句练习
前言这个学期有数据库原理这门课,其中很重要的一个部分就是SQL查询语句的练习。但是自己手写的查询语句如果不测试的话是不知道是否正确的,而也不可能指望老师会检查每个人的查询语句的正确性。所以只能自力更生,亲自实践,测试查询语句的正确性。MySQL环境搭建1.首先到官网下载MySQL(http://dev.mysql.com/downloads/),并解压缩到D:\mysql-5.7.15-winx64
2016-10-07 21:39:31 1225
wireshark中文版
2015-03-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人