上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 48 下一页
  2012年10月7日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1371树形DP 不过一遍DFS 就能可以需要注意的 是 N=50000 时 需要用 long long 或者 unsigned int还有超栈的话 需要 自己可一个较大的栈区代码:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<vector>#include<queue>#include<map>#includ 阅读全文
posted @ 2012-10-07 14:41 夜-> 阅读(238) 评论(0) 推荐(0) 编辑
  2012年10月5日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1326状态压缩DP题目大意:要买某几种 tap 每种买一个 既可以单个买 也可以成套买求最优买法.思路:dp[i] 表示 i 状态下的最优买法 即最少的花钱先初始化 dp[i] 求出单个买的花费再用成套的买法进行优化 选取符合要求的最优值代码及其注释:#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<vector>#include< 阅读全文
posted @ 2012-10-05 14:32 夜-> 阅读(320) 评论(0) 推荐(0) 编辑
  2012年9月27日
摘要: 递推水题import java.util.*;import java.math.*;public class Main { public static void main(String[] args) { int n; Scanner in = new Scanner(System.in); while (in.hasNext()) { n = in.nextInt(); if (n == 0) { break; } int num0[][] = new int[n + 1][n + 1];//图形从上向下 此列连续的 0 的个数 int num1[][] = ... 阅读全文
posted @ 2012-09-27 09:23 夜-> 阅读(245) 评论(0) 推荐(0) 编辑
  2012年9月26日
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1611DP 递推显然这个题是可能有多组解的 求最优解+记录路径即可当 i 个 conductors 和 j 个 dodgers 时 最后的人可能是 conductor 也可能是 dodger 枚举这两种情况最优即可代码及其注释:#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <queue>#include <vector 阅读全文
posted @ 2012-09-26 18:23 夜-> 阅读(326) 评论(0) 推荐(0) 编辑
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1437好水的数据呀 dfs 都能过代码:#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <queue>#include <vector>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:10240 阅读全文
posted @ 2012-09-26 16:24 夜-> 阅读(223) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4417线段树 or 树状数组 都可以先把问题 和 和 砖块 分别按高度排序在求解区间答案时 根据要求的高度 将小于这个高度的砖块全部插入 再求解即可代码:#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <queue>#include <vector>#include <algorithm>#define LL lon 阅读全文
posted @ 2012-09-26 10:16 夜-> 阅读(242) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4414简单枚举代码:#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <queue>#include <vector>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:1024000000,1024000000& 阅读全文
posted @ 2012-09-26 09:40 夜-> 阅读(136) 评论(0) 推荐(0) 编辑
  2012年9月25日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4415把原数据分两组 一组 B 为 0 另一组 B 不为 0B 不为 0 的那组 要么不死 要么全死对于 B 全死的情况 这一组里面的人 主角可以用自己的剑杀死 也可以用敌人的剑杀死如果用自己的剑杀死 如果杀死一个人 一定是 A 最小的那一个 如果是两个人 一定是 A 最小的那两个枚举 比较最优解代码及其注释:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#includ 阅读全文
posted @ 2012-09-25 18:16 夜-> 阅读(194) 评论(0) 推荐(0) 编辑
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1223DP 神一般的维度转换最简单的想法就是 dp[ i ][ j ] i 个蛋 j 层楼 最少需要多少次试验如果只有一个 蛋 则需要试验 j 次 否则:dp[ i ][ j ] =min( dp[ i ][ j ] , max ( dp[ i ][ j-w] , dp[ i-1] [w-1]) ); ( w<=j&&w>=1 ) (w 表示开始选择哪个楼层)虽然这样很好理解 但是 需要枚举 w 所以时间复杂度可以达到 1000^3 太高我们可以想象 在蛋的个数确定的 阅读全文
posted @ 2012-09-25 16:44 夜-> 阅读(255) 评论(0) 推荐(0) 编辑
  2012年9月24日
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4405代码:#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <vector>#include <algorithm>#define LL long long//#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;c 阅读全文
posted @ 2012-09-24 19:33 夜-> 阅读(172) 评论(0) 推荐(0) 编辑
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 48 下一页