自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 不考虑价值的背包问题

背包问题:假设有一个能装入总体积为T的背包和n件体积分别为W1,W2,…,Wn的物品, 能否从n件物品中挑选若干件恰好装满背包, 使W_i1+W_i2+…+W_in=T,要求找出所有满足上述条件的解。#include<iostream>#include<vector>#include<stack>using namespace std;struct

2017-12-28 15:21:05 3033

原创 安全hash算法,sha-1的C++实现

#include<iostream>#include<string>#include<vector>#include<cmath>#include<stack>using namespace std;#define NUM 8 //一个字等价于8个16进制数 #define HEX 16 //16进制 #define BIT 512 //消息认证码512 bite一组class

2017-12-10 14:00:39 3053 1

原创 8.8 精确的4SAT问题的NP-完全性证明

问题:在精确的 4SAT 问题中,输入为一组子句,,每个字句都是恰好4个文字的析取,且每个变量最多在每个子句中出现一次。目标是求它的满足赋值——如果该赋值存在。证明精确的 4SAT 是NP-完全问题。证明如下:由于 3SAT 问题是 NP - 完全问题,所以如果能够从 3SAT 归约到精确的 4SAT 问题,那么精确的 4SAT 问题也是 NP - 完全问题。下面是归约过程:第一步

2017-07-11 15:15:24 568

原创 Different Ways to Add Parentheses

Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example 1

2017-06-12 23:15:25 193

原创 动态规划问题

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan

2017-05-15 19:53:26 182

原创 sort算法案例

题目:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.

2017-04-10 19:44:32 290

原创 graph

问题: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

2017-03-20 17:55:05 152

原创 简单分治案例

题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the

2017-03-13 13:11:35 209

原创 简单归并排序

问题:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, r

2017-03-05 17:34:58 278

原创 简单算法解答

题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use

2017-02-26 14:40:38 238

空空如也

空空如也

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

TA关注的人

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