Intuitively there must a O(n) solution.First I tried a bottom-up DP solution but it had a TLE:class Solution {public: int maxProduct(int A[], int n...
分类:
其他好文 时间:
2014-10-11 08:50:25
阅读次数:
141
>_ 2 #include 3 #include 4 using namespace std; 5 6 int _tmain(int argc, _TCHAR * argv[]) 7 { 8 9 int data1=0x000000;10 int data2=0x00000F;1...
分类:
编程语言 时间:
2014-10-11 05:01:24
阅读次数:
200
生成word时,有时用户要求要生成所有级别的目录。这个时候就需要计算目录树的深度。关于求树的深度,已有很多现成的算法。本文主要介绍一种linq的写法。代码看起来挺简洁的。public static int MenuDepth(List menuList, int parentId) {...
分类:
其他好文 时间:
2014-10-11 03:54:54
阅读次数:
197
题目链接:http://poj.org/problem?id=1159思路: 对该问题的最优子结构与最长回文子序列相同。根据最长回文子序列的状态方程稍加改变就可以得到该问题动态方程。代码:#include #include const int MAX_N = 5000 + 10;int dp[MA....
分类:
其他好文 时间:
2014-10-11 02:49:14
阅读次数:
183
题目链接:http://poj.org/problem?id=3624思路: 经典的0-1背包问题: 分析如下:代码:#include using namespace std;const int MAX_N = 12880 + 10;int dp[MAX_N], W[MAX_N], D[MAX_.....
分类:
其他好文 时间:
2014-10-11 02:39:54
阅读次数:
199
word中导出目录是一个常见的问题。详细代码如下:public static void ExportMenu(int maxLevel, Document word) //利用标题样式生成目录 { //GoToTheBeginning(word); ...
分类:
其他好文 时间:
2014-10-11 02:31:04
阅读次数:
264
现在两种情况:第一种情况:using System;namespace Wrox{ public class Program { static void Main(string[] args) { int index; ...
题目链接:http://poj.org/problem?id=1458思路: 经典的最长公共子序列问题,使用动态规划解题。代码:#include #include using namespace std;const int MAX_N = 200 + 10;int dp[MAX_N][MAX_N]....
分类:
其他好文 时间:
2014-10-11 02:14:34
阅读次数:
201
练习一要求 : 在控制台中人工输入任意十个数值,最后求十个数值的合。首先要将输入的数值定义:1)整型定义 以int为例:int a = Convert.ToInt(Console.ReadLine())2)浮点定义以double为例:double a = Convert.ToDouble(Conso...
分类:
其他好文 时间:
2014-10-11 01:57:44
阅读次数:
202
实例代码:
class Resource
{
String name;
String sex ;
}
class Input implements Runnable
{
Resource r;
Input(Resource r)
{
this.r = r;
}
public void run()
{
int x = 0;
while(true)
{
sync...
分类:
编程语言 时间:
2014-10-11 01:17:24
阅读次数:
274