STL中的神器next_permutation和prev_permutation函数
全排列...
分类:
其他好文 时间:
2014-06-24 22:41:03
阅读次数:
271
Given a collection of integers that might contain duplicates, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplica...
分类:
其他好文 时间:
2014-06-24 20:58:32
阅读次数:
230
【题目】
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 one and sell one share of the stock multiple times). H...
分类:
其他好文 时间:
2014-06-24 19:40:53
阅读次数:
240
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1-...
分类:
其他好文 时间:
2014-06-22 22:57:49
阅读次数:
347
题目:
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.
...
分类:
其他好文 时间:
2014-06-22 17:51:54
阅读次数:
196
1、
??
Subsets
Given a set of distinct integers, S, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.The solution set must not contain duplicate subset...
分类:
其他好文 时间:
2014-06-22 17:08:53
阅读次数:
179
题目来源:Light OJ 1288 Subsets Forming Perfect Squares
题意:给你n个数 选出一些数 他们的乘积是完全平方数 求有多少种方案
思路:每个数分解因子 每隔数可以选也可以不选 0 1表示 然后设有m种素数因子 选出的数组成的各个因子的数量必须是偶数
组成一个m行和n列的矩阵 每一行代表每一种因子的系数 解出自由元的数量
#include
#inc...
分类:
其他好文 时间:
2014-06-22 16:24:23
阅读次数:
198
题目:Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your...
分类:
其他好文 时间:
2014-06-22 13:49:21
阅读次数:
243
N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, retu...
分类:
其他好文 时间:
2014-06-22 13:10:11
阅读次数:
188
题目链接:点击打开链接
= = 990+ms卡过
#include
#include
#include
#include
#include
#include
using namespace std;
#define N 100010
#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define ll int
ll n,m,k,a,b;
ll x[N];
b...
分类:
其他好文 时间:
2014-06-22 08:16:57
阅读次数:
208