泛泛解:D:求K大,如果我们二分枚举,如果有O(N)的方法统计,就OK了,先枚举,我们对每一行的统计能够达到O(1),所以很简单了。E:有思路,但是代码能了太弱了,DFS学得太水。 我们发现其实就是一个深度递归结构,只有100000个元素,所以这是一个突破点。 先求出所有因子,然后枚举因子,出现的话...
分类:
其他好文 时间:
2014-07-19 17:12:13
阅读次数:
244
直接枚举计算就行;#include#include#include#define maxn 22using namespace std;double ans[maxn],p[maxn];bool vis[maxn];int n,r;void dfs(int cur,int cot){ if(c...
分类:
其他好文 时间:
2014-07-19 15:37:13
阅读次数:
158
class Solution {public: vector generateParenthesis(int n) { string str; vector res; dfs(n, 0, 0, str, res); return res;...
分类:
其他好文 时间:
2014-07-19 15:28:21
阅读次数:
207
题意:一个送披萨的,每次送外卖不超过10个地方,给你这些地方之间的时间,求送完外卖回到店里的总时间最小。解法一: 这个n不大即使是NP问题也才1E6多一些所以可以dfs();具体的回溯方法结合dance link 就可以; #include #include #include #include .....
分类:
其他好文 时间:
2014-07-19 14:12:38
阅读次数:
148
题目:codeforces 448CPainting Fence
题意:n个1* a [ i ] 的木板,把他们立起来,变成每个木板宽为1长为 a [ i ] 的栅栏,现在要给栅栏刷漆,刷子宽1,每一刷子可以刷任意长,现在让你求最少需要多少刷子?
分析:题目看似没有头绪,仔细分析的话其实很简单
首先,我们假如每次都刷一个木板,即一竖行,那么需要n次刷完,可见这是一个a...
分类:
其他好文 时间:
2014-07-19 02:35:45
阅读次数:
184
The best way to learn DP from DFS! Nice problem.My intuition is that it can be solved by DFS:class Solution {public: int climbStairs(int n) { ...
分类:
其他好文 时间:
2014-07-18 17:24:53
阅读次数:
188
Problem Description
可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习以为常,她深信智勇的骑士LJ肯定能将她救出。 现据密探所报,公主被关在一个两层的迷宫里,迷宫的入口是S(0,0,0),公主的...
分类:
其他好文 时间:
2014-07-18 12:38:25
阅读次数:
249
Tempter of the BoneTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 68206Accepted Submission(s): 18...
分类:
其他好文 时间:
2014-07-18 12:09:55
阅读次数:
211
Description
Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Silver, Silver, Bronze, Bronze, Bronze, Go...
分类:
其他好文 时间:
2014-07-18 11:23:05
阅读次数:
280
Given a binary tree containing digits from 0-9 only,
each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents
the number 123.
Find the to...
分类:
其他好文 时间:
2014-07-18 11:13:57
阅读次数:
204