#include #include #include #include #include #define MAX 30using namespace std;/* 一道很好的递推题,虽然思路是从discuss中获得,但是应该想简单些,从前一次走可获得, 每次向上走可以为下一次获得3步机会,而向左或者...
分类:
其他好文 时间:
2015-01-29 14:03:45
阅读次数:
161
给一个序列,如果经过k次冒泡能使其变为单增序列,则称该序列为k回合冒泡序列
现在给你n,k, 问在n的全排列中,k回合冒泡序列有多少个
这题看规模就是要推一个公式出来
discuss里的一个解法非常好,让人可以理解
对于n个元素,假设为{0,1,...n- 1},可以发现
对于任意一个排列,假设L(i) 表示位置i上的元素的前面有多少数字比它大, 那么得到了一个L序列。
那么可...
分类:
编程语言 时间:
2015-01-23 16:23:30
阅读次数:
131
http://www.cnblogs.com/TenosDoIt/p/3214096.htmlhttp://blog.csdn.net/myan/article/details/647511http://www.mysanco.cn/wenda/index.php?class=discuss&act...
分类:
其他好文 时间:
2015-01-21 18:04:48
阅读次数:
145
Introduction
I own a HTC Dream. While one may discuss about its usability as a phone, it makes a great portable internet access machine. I have installed a debian chroot on that machine and used to...
分类:
移动开发 时间:
2015-01-13 14:26:44
阅读次数:
236
本题最机巧的O(n)解法最早由1337c0d3r于2013.11.26发布在leetcode。之后看到类似的,都系转载、引用或抄袭。(原文:https://oj.leetcode.com/discuss/857/constant-space-solution)
大多数转载都写得语焉不详,有的甚至据为己有。本帖旨在全面解析该算法。
如下:
int singleNumber(int A[], i...
分类:
其他好文 时间:
2014-12-14 14:40:03
阅读次数:
161
html4 doctype HTML5 doctype: In this example page, the root element looks like this: The first thing to discuss is the xmlns attribute. This is a...
分类:
Web程序 时间:
2014-11-28 21:17:42
阅读次数:
323
题目:Implementint sqrt(int x).Compute and return the square root ofx思路:1、利用二分法查找 2、Discuss里面贴了一些利用移位做的方法;BTW: C++11定义的Sqrt函数 from double sqrt (doubl...
分类:
其他好文 时间:
2014-11-13 01:48:07
阅读次数:
119
题目大意:有1~6六种宝石,价格分别为1~6 。。给定每种宝石的个数,问能否平分给两个人分析:一看显然是个多重背包问题,也可以用母函数做不过母函数的复杂度是n*v*k,第一次tle了。。后来发现一种优化方式当个数大于 6的时候直接把个数设为 5(奇数),6(偶数)。。discuss 里面有位神牛给出...
分类:
其他好文 时间:
2014-11-11 18:26:30
阅读次数:
168
An Easy ProblemDescriptionAs we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and i...
分类:
其他好文 时间:
2014-11-10 17:39:08
阅读次数:
196
最少跳跃步数
第一想法是DP,复杂度O(n^2),但是对于大型数据会超时。
Discuss中一种犀利的贪心方法,复杂度为O(n)
class Solution {
public:
int jumpDP(int A[], int n) {//DP方法
int *dp=new int[n],j;
memset(dp,127,sizeof(int)*n);
dp[0...
分类:
其他好文 时间:
2014-11-09 18:07:19
阅读次数:
143