上一页 1 2 3 4 5 6 7 8 ··· 11 下一页
摘要: 求dp比较水。。但是打印路径很蛋疼。。搞了好久还学习了别人的递归写法题目:背景给定一个正整数序列a(1),a(2),...,a(n),(1 2 using namespace std; 3 #define INF 999999 4 int n; 5 int num[30]; 6 int sum[30]; 7 int dp[30][30]; 8 int G[30][30]; 9 10 int dfs( int L ,int R)11 {12 int &d = dp[L][R];13 if( d !=INF) return d;14 15 if(L == R) return... 阅读全文
posted @ 2014-02-01 23:30 doubleshik 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 一道不知道是不是树形dp的水题。。就是选了一个点不能选他的父亲和儿子。 求一个最大值见代码描述Arthur公司是一个等级森严的公司,它们有着严格的上司与下属的关系,公司以总 裁为最高职位,他有若干个下属,他的下属又有若干个下属,他的下属的下属又有若干个下属……现接近年尾,公司组织团拜活动,活动中有一部分是自由舞会,公 司的每个职员都有一个搞笑值,现要你制定一套哪些人上台的方案,使得台上所有演员的搞笑值最大。当然,职员们是不会和他们的顶头上司一起上台的。格式输入格式第一行一个整数N,表示这个公司总共的职员个数。接下来一行有N个整数,由空格隔开,第i个整数表示职员i的搞笑值Ai(-1327670≤ 阅读全文
posted @ 2014-02-01 22:22 doubleshik 阅读(222) 评论(0) 推荐(0) 编辑
摘要: dp[l,r] =max(dp[l,k]*dp[k+1,r] + G[k] ) l 2 using namespace std; 3 #define LL long long 4 int n; 5 int mid[50]; 6 int first[50][50]; 7 int dp[50][50]; 8 int dfs(int L,int R) 9 {10 int &d = dp[L][R];11 if(d)return d;12 if( R-L ==1)13 {14 first[L][R] = L;15 ... 阅读全文
posted @ 2014-02-01 22:20 doubleshik 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 就是找出最长的一个回文串 。。 一开始用了个朴素的dp。。结果应该是内存爆了开不了那么大数组。 然后就暴力枚举了回文的中间数字。过了。。感觉还是太低效题目: Calf Flac It is said that if you give an infinite number of cows an infinitenumber of heavy-duty laptops (with very large keys), that they willultimately produce all the world's great palindromes. Your job will beto d 阅读全文
posted @ 2014-01-31 20:50 doubleshik 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 题目大意就是用最多M 块木板去修天花板, 要求最后用掉的木板长度最小。这道题最好的是用贪心解。 做的时候我用了dp想法比较简单, 参考nocow 贪心的想法比较巧妙感觉题目:Barn RepairIt was a dark and stormy night that ripped the roof and gates off the stalls that hold Farmer John's cows. Happily, many of the cows were on vacation, so the barn was not completely full.The cows sp 阅读全文
posted @ 2014-01-31 19:24 doubleshik 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 题目大意就是给出 N门课, 然后给出每门课花m天的收益,问在天数一定的情况下最大收益ans[x][r] 表示前x节课在r天的情况下的最佳情况for ( int i= 0, r)ans[x][r] = max( ans[x][r] , ans[x+1][r-i] + cl[x][i])用了for和dfs两种方法写题目:ACboy needs your helpTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3368Accepted Submiss 阅读全文
posted @ 2014-01-11 23:28 doubleshik 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 枚举n/2个区间,判断 区间内的h和t是不是总数一半,是的话区间左边切一刀,右边切一刀( 一共最多切两刀)题目:Ice-sugar GourdTime Limit: 5000/2000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 740Accepted Submission(s): 264Problem DescriptionIce-sugar gourd, “bing tang hu lu”, is a popular snack in Beijing of China. It i 阅读全文
posted @ 2014-01-11 22:56 doubleshik 阅读(702) 评论(0) 推荐(0) 编辑
摘要: 用记忆化搜索做了一下题目:P1104采药Accepted标签:NOIP普及组2005[显示标签]描述辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有 威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到一个到处都是草药的山洞里对他说:“孩子,这个山洞里有一些不同的草药,采每一株 都需要一些时间,每一株也有它自身的价值。我会给你一段时间,在这段时间里,你可以采到一些草药。如果你是一个聪明的孩子,你应该可以让采到的草药的总价 值最大。” 如果你是辰辰,你能完成这个任务吗?格式输入格式输入的第一行有两个整数T(1 4 #include 5 #incl.. 阅读全文
posted @ 2014-01-11 22:53 doubleshik 阅读(316) 评论(0) 推荐(0) 编辑
摘要: win下脚本在linux 下写 #!/usr/bin/python3 时候 出现 /usr/bin/python3^M: 坏的解释器: 类似的问题应该是类似\r\n 等问题。 用一个工具 dos2unix + 脚本名字解决 阅读全文
posted @ 2014-01-07 16:04 doubleshik 阅读(514) 评论(0) 推荐(0) 编辑
摘要: 这道题数据s不是100。。我开了1000。。坑。。不停RE做法就是求出一个最小生成树然后求 第n-s边的大小题目:Problem C: Arctic NetworkThe Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a 阅读全文
posted @ 2014-01-07 14:40 doubleshik 阅读(159) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 11 下一页