08 2012 档案

摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=666本来是找背包问题做的. 搜到这题, 结果完全没有背包的思路, 看了别人的题解. 也不觉得是背包.....⊙﹏⊙b汗View Code 1 #include <iostream> 2 #define maxn 305 3 using namespace std; 4 int ans[maxn], v[20]; 5 int main() 6 { 7 int i, j, m, count; 8 for(i = 1; i <= 17; i++) 9 v[... 阅读全文
posted @ 2012-08-31 16:34 YORU 阅读(141) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=4560/1背包问题View Code 1 #include <iostream> 2 #define maxn 100005 3 using namespace std; 4 int ans[maxn], v[maxn]; 5 int main() 6 { 7 long t, n, i, j, sum, m; 8 cin >> t; 9 while(t--)10 {11 cin >> n;12 sum = 0;13 ... 阅读全文
posted @ 2012-08-31 12:01 YORU 阅读(163) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1059很弱....时间是750ms....View Code 1 #include <iostream> 2 #define n 7 3 #define maxn 125005 4 using namespace std; 5 int main() 6 { 7 long t=0, i, j, l, sum, ans[maxn], v[n], num[n], m; 8 while(1) 9 {10 t++;11 sum = 0;12 fo... 阅读全文
posted @ 2012-08-31 10:20 YORU 阅读(202) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1171我坑在了两个地方, 首先看到-1的时候就结束, 然后就是-1了. 再是数组的范围我一直以为是 100*1000 的, 结果还是小.这题为多重背包, 其中 V , W 的值是相同的. 是不是可以用什么单调队列优化?.....View Code 1 #include <iostream> 2 #define maxn 125005 3 using namespace std; 4 long ans[maxn], v[maxn], num[maxn], n, m; 5 void complete_ 阅读全文
posted @ 2012-08-30 21:24 YORU 阅读(153) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2191题目是多重背包的题目,但是我们可以写成是0/1背包的格式。0/1背包的代码:View Code 1 #include <iostream> 2 #define maxn 101 3 using namespace std; 4 int ans[maxn], v[maxn], w[maxn], num[maxn]; 5 int main() 6 { 7 int i, j, l, n, m, t; 8 cin >> t; 9 while(t--)10 {11 ... 阅读全文
posted @ 2012-08-30 16:46 YORU 阅读(414) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1114在0/1背包中有说,当只有f[0]=0,其他值为-∞时,可以求到恰好是装满时的最大值.这题应用这个原理,即只有f[0]=0,其他的都不为0,应该讲它设置为+∞,则恰好可以求到装满时的最小指.View Code 1 #include <iostream> 2 #define maxn 10005 3 #define M 505 4 using namespace std; 5 int ans[maxn], v[M], w[M]; 6 int main() 7 { 8 int t, n, m, 阅读全文
posted @ 2012-08-30 11:13 YORU 阅读(146) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1248完全背包....View Code 1 #include <iostream> 2 #define maxn 10005 3 using namespace std; 4 int ans[maxn],v[3]; 5 int main() 6 { 7 int n, t, i, j; 8 v[0] = 150; 9 v[1] = 200;10 v[2] = 350;11 cin >> t;12 while(t--)13 {14 cin... 阅读全文
posted @ 2012-08-30 09:21 YORU 阅读(198) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1203依旧是0/1背包的问题. 水题,秒杀之。。O(∩_∩)O哈哈~View Code 1 #include <stdio.h> 2 #define maxn 10005 3 double ans[maxn], w[maxn]; 4 int v[maxn]; 5 int main() 6 { 7 int n, m, i, j; 8 while(~scanf("%d%d",&m,&n),n||m) 9 {10 for(i = 0; i < n; i++)11 阅读全文
posted @ 2012-08-29 21:36 YORU 阅读(157) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2602水题一道,依旧是0/1背包的问题。。。加深理解O(∩_∩)O~View Code 1 #include <iostream> 2 #define maxn 1005 3 using namespace std; 4 long ans[maxn], v[maxn], w[maxn]; 5 int main() 6 { 7 long t, n, m, i,j; 8 cin >> t; 9 while(t--)10 {11 cin >> n >> m;12 .. 阅读全文
posted @ 2012-08-29 20:38 YORU 阅读(131) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2546依旧是0/1背包的问题。 只是 v,w相同。View Code 1 #include <iostream> 2 #include <algorithm> 3 #define maxn 1005 4 using namespace std; 5 int f[maxn],v[maxn]; 6 7 int main() 8 { 9 int n, m, i, j;10 while(cin >> n, n)11 {12 for(i = 0; i < n; i++)13 . 阅读全文
posted @ 2012-08-29 17:12 YORU 阅读(186) 评论(0) 推荐(0)
摘要:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=4183初学 0/1 背包,准备开始看背包.....View Code 1 #include <iostream> 2 #define maxn 1001 3 using namespace std; 4 int f[maxn][maxn], v[maxn], w[maxn], mark[maxn]; 5 int main() 6 { 7 int i, j, n, m, l, now; 8 cin >> n >> m; 9 for(i = 0; i <= 阅读全文
posted @ 2012-08-29 15:51 YORU 阅读(160) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1671字典树的题目,在POJ上的时候字典树的话会因为不断开辟新的节点而消耗过多的时间,所以会开一个固定的空间.....但是我不知道该开多大的空间....o(╯□╰)o看别人的代码是开到 100000...话说我不知道为什么只要那么点就可以了....Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <iostream> 5 using namespace 阅读全文
posted @ 2012-08-29 09:54 YORU 阅读(138) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4262树状数组更新点的位置,并可以求出两点之间的有多少球View Code 1 #include <stdio.h> 2 #define maxn 100001 3 int ans[maxn], n, b[maxn]; 4 5 int lowbit(int x) 6 { 7 return x & (-x); 8 } 9 10 void mod(int x, int data)11 {12 int i;13 for(i = x; i <= n; i+=lowbit(i))14 ... 阅读全文
posted @ 2012-08-28 21:15 YORU 阅读(218) 评论(0) 推荐(0)
摘要:Cinema in AkibaTime Limit:3 Seconds Memory Limit:65536 KBCinema in Akiba (CIA)is a small but very popular cinema inAkihabara. Every night the cinema is full of people. The layout ofCIAis very interesting, as there is only one row so that every audience can enjoy the wonderful movies without any anno 阅读全文
posted @ 2012-08-26 21:08 YORU 阅读(446) 评论(2) 推荐(0)