上一页 1 ··· 5 6 7 8 9 10 11 12 下一页
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=100暴力也可以,但是应该和谐..http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.html在这里看到了别的做法View Code 1 #include <stdio.h> 2 int main() 3 { 4 int n,num,t; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%d",&n); 9 num=0;10 阅读全文
posted @ 2012-09-07 18:03 YORU 阅读(159) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1257找数列中递减数列的个数....View Code 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 const int maxn=1000005; 5 int ans[maxn],num; 6 bool f[maxn]; 7 int main() 8 { 9 int n,i,t,j;10 while(~scanf("%d",&n)){11 for(i=0;i<n; 阅读全文
posted @ 2012-09-06 21:19 YORU 阅读(161) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2689这题冒泡能过,反正我是归并的....题目就是求逆序对..View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn=101; 4 int ans[maxn][maxn],v[maxn],w[maxn]; 5 int main() 6 { 7 int n,m,k,s,i,j,l,max; 8 while(cin>>n>>m>>k>>s) 9 {10 max=-1; 阅读全文
posted @ 2012-09-06 20:39 YORU 阅读(168) 评论(0) 推荐(0)
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2159二维的背包问题....个人感觉是0/1背包和完全背包的结合.View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn=101; 4 int ans[maxn][maxn],v[maxn],w[maxn]; 5 int main() 6 { 7 int n,m,k,s,i,j,l,max; 8 while(cin>>n>>m>>k>>s) 9 {10 max=- 阅读全文
posted @ 2012-09-06 19:58 YORU 阅读(171) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=267好烦....View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1005 4 char stack[maxn],str[maxn],source[maxn],aim[maxn][10]; 5 double num[maxn],s[maxn]; 6 int main() 7 { 8 int i,j,l,k,t,le,rear,f=0,mark,iter; 9 double a... 阅读全文
posted @ 2012-09-05 21:19 YORU 阅读(196) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=257栈的应用....View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1005 4 char stack[maxn],str[maxn],source[maxn]; 5 int main() 6 { 7 int i,j,l,k,t,le,rear; 8 scanf("%d",&t); 9 while(t--)10 {11 scanf("%s" 阅读全文
posted @ 2012-09-05 20:10 YORU 阅读(189) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=228本想用树状数组的, 结果有点囧...........然后看了别的大牛的做法.... 离线查询的可以有o(n)的算法...View Code 1 2 #include <iostream> 3 #include <stdio.h> 4 using namespace std; 5 const int maxn = 1000005; 6 const int M = 10003; 7 int ans[maxn]; 8 int main() 9 {10 int n, m, q 阅读全文
posted @ 2012-09-05 12:17 YORU 阅读(209) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=123这题本来交上去就超时了, 然后自己就囧了.... 不知道该用什么更高级的结构了...然后去百度的题解....看到的是和我一样的思路, 但怎么就过了呢.. 仔细看了下, 别人的更新都是从当前点更新到0位置.然而我是从当前点, 更新到数组的结尾, 结果就不行了.然后自己改了下代码就过了......感觉是数据出的问题,偏向了某一边把....用线段树是不是会更好呢?View Code 1 #include <iostream> 2 #include <stdio.h> 3 # 阅读全文
posted @ 2012-09-04 22:24 YORU 阅读(251) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=116和 士兵杀敌(一) 是一样的。View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1000005; 5 int ans[maxn], n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 int getSum(int x)12 {13 int i, sum=0;14 f 阅读全文
posted @ 2012-09-04 21:34 YORU 阅读(134) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=108线段树,或者树状数组View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1000005; 5 int ans[maxn], n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 int getSum(int x)12 {13 int i, sum=0;14 for(i 阅读全文
posted @ 2012-09-04 21:14 YORU 阅读(151) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页