
算法题解
文章平均质量分 77
daxiongrong
这个作者很懒,什么都没留下…
展开
-
背包 dp 双重动态规划
Raucous Rockers“破锣摇滚”乐队译 by Maigo Akisame你刚刚继承了流行的“破锣摇滚”乐队录制的尚未发表的N(1 不巧你是一位古典音乐迷,不懂如何判定这些歌的艺术价值。于是你决定根据以下标准进行选择: 歌曲必须按照创作的时间顺序在CD盘上出现。 选中的歌曲数目尽可能地多。 PROGRAM NAME: rockersINPUT FORMAT第一行: 三个整数:N, T, M. 第二行: N个整数,分别表示每首歌的长度,按创作时间顺序排列。 SAMPLE I翻译 2010-08-29 11:49:00 · 2164 阅读 · 1 评论 -
POJ 2777 Count Color 线段树一些容易遗漏的东西……
成段更新,区间统计,把query里的传递给子节点的步骤,切记!!向大牛学习……http://www.notonlysuccess.com/?p=59#includeusing namespace std;int countbit(unsigned int n){ int count=0; while(n!=0) { n &= n-1; count++; } return count;}int two(int n){原创 2010-11-17 00:43:00 · 454 阅读 · 0 评论 -
高精度乘法,支持浮点运算。POJ 1001 Exponentiation 顺便总结一下string的常用函数
第一次使用string的insert() 函数,该函数有好几个重载,所以在传参数时要明确地给予类型转换。插入(insert) 语法: iterator insert( iterator i, const char &ch );basic_string &insert( size_type index, const basic_string &str );basic_string &insert( size_type index, const char *str );basic_string &insert(原创 2010-11-10 23:03:00 · 671 阅读 · 0 评论 -
poj 2528 Mayor's posters 离散化 线段树
<br />#include<iostream>#include<algorithm>#include<vector>using namespace std;struct gg{ int x; int id; gg(){} gg(int xx,int idd) { x=xx; id=idd; }};bool cmp(gg a,gg b){ return a.x<b.x;}int main(){原创 2010-12-17 23:37:00 · 557 阅读 · 0 评论 -
sicily 1802. Atomic Nucleus Investigation
<br />终于自己能找出线段树的错误了。<br />#include<cstdio>#include<iostream>using namespace std;const int inf=1<<30;struct seg_tree{ int left; int right; int _max; int _min; int cha; int calmid() { return (left+right)>>1; }};seg_tree原创 2010-12-14 13:17:00 · 436 阅读 · 0 评论 -
注意广度搜索时访问过的点如何标记
<br />题目:紧急援救<br /> 问题编号:34 题目描述<br /> 话说2007年8月5日,Mike博士神秘失踪了,最后发现是被外星人绑架了,幸好外星人目前还是在地球上活动,并且知道外星人不了解地球,幸好,Milk博士身上有无线信号发送装置,我们终于确定了他的位置,必须赶快到那里去救他。<br /> 根据无线信号发送装置,我们确定出一张地图,为了尽快寻找到Mike博士,于是这个光荣和艰巨的任务便交给了你,编写程序,通过使用一张地图帮助研究所确定从研究所出原创 2010-12-08 18:03:00 · 803 阅读 · 0 评论 -
背包问题第k优解
题目:多人背包 问题编号:123 RQNOJ题目描述 DD 和好朋友们要去爬山啦!他们一共有 K 个人,每个人都会背一个包。这些包的容量是相同的,都是 V。可以装进背包里的一共有 N 种物品,每种物品都有给定的体积和价值。在 DD 看来,合理的背包安排方案是这样的:每个人背包里装的物品的总体积恰等于包的容量。 每个包里的每种物品最多只有一件,但两个不同的包中可以存在相同的物品。 任意两个人,他们包里的物品清单不能完全相同。 在满足以上要求的前提下,所有包原创 2010-12-07 19:22:00 · 2388 阅读 · 0 评论 -
RQNOJ 329 二维背包 顺便收集整理一下相关资料
今天做这题,wa了很多次。原来是01背包没学好。以下是优化空间复杂度后的程序#include#includeusing namespace std;const int maxn=200;struct let{ int val; int time; int h; int w;};bool operator >n>>m>>t; for(int i=1;i>a[i].val>>a[i].time>>a[i].h>>a[i].w;原创 2010-09-04 19:47:00 · 441 阅读 · 0 评论 -
usaco /money
<br />/*<br />PROG: money<br />ID: daxiong1<br />LANG: C++<br />*/<br /><br />#include<iostream><br />#include<fstream><br />using namespace std;<br />long long aa[26][10001];<br />long long bb[26];<br />int main(){<br />ifstream cin("money.in");<br />//if原创 2010-08-31 10:50:00 · 397 阅读 · 0 评论 -
Timus 1225. Flags dp
1225. FlagsTime Limit: 1.0 secondMemory Limit: 16 MBOn the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions: Stripes of t原创 2010-08-30 23:58:00 · 1031 阅读 · 0 评论 -
hdu 1698 Just a Hook 线段树
终于自己写出线段树了。成段更新,成段查询,对于这类型的题目,要注意状态的继承就不会有什么问题了。非常感谢在博客上分享代码的acmer ,你们都是我的教师啊。以下的代码也是学习别人的风格,因为觉得很好。#includeusing namespace std;struct seg_tree{ int left; int right; int val; bool cov; int原创 2010-12-13 22:02:00 · 318 阅读 · 0 评论