会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
SXISZERO
ACM-ICPC
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
9
···
13
下一页
2015年3月22日
[POJ] 2785 4 Values whose Sum is 0(双向搜索)
摘要: 题目地址:http://poj.org/problem?id=2785 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #i...
阅读全文
posted @ 2015-03-22 20:00 SXISZERO
阅读(196)
评论(0)
推荐(0)
2015年3月21日
[POJ] 3320 Jessica's Reading Problem (尺取法)
摘要: 题目地址:http://poj.org/problem?id=3320 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #i...
阅读全文
posted @ 2015-03-21 21:40 SXISZERO
阅读(207)
评论(0)
推荐(0)
[POJ] 3061 Subsequence (尺取法)
摘要: 题目地址:http://poj.org/problem?id=3061方法一:因为元素都大于0,所以维护前缀和sum[i],一定有sum[k]>sum[i](k>i)。这样子序列起点s确定以后,用二分查找确定使序列和不小于s的结尾t的最小值。 时间复杂度o(nlogn)。 1 #include...
阅读全文
posted @ 2015-03-21 10:14 SXISZERO
阅读(167)
评论(0)
推荐(0)
2015年3月20日
最大化平均值 (二分查找)
摘要: 有n个物品的重量和价值分别是wi和vi。从中选出k个物品使得单位重量的价值最大。 1 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #inclu...
阅读全文
posted @ 2015-03-20 20:35 SXISZERO
阅读(182)
评论(0)
推荐(0)
[POJ] 2456 Aggressive cows (二分查找)
摘要: 题目地址:http://poj.org/problem?id=2456最大化最小值问题。二分牛之间的间距,然后验证。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #...
阅读全文
posted @ 2015-03-20 09:59 SXISZERO
阅读(228)
评论(0)
推荐(0)
2015年3月19日
[POJ] 1064 Cable master (二分查找)
摘要: 题目地址:http://poj.org/problem?id=1064有N条绳子,它们的长度分别为Ai,如果从它们中切割出K条长度相同的绳子,这K条绳子每条最长能有多长。二分绳子长度,然后验证即可。复杂度o(nlogm) 1 #include 2 #include 3 #include 4 #inc...
阅读全文
posted @ 2015-03-19 16:29 SXISZERO
阅读(179)
评论(0)
推荐(0)
二分查找
摘要: 时间复杂度o(nlogn)。STL中为lower_bound,upper_bound。 1 int bin_search(int *a,int h,int t,int k) 2 { 3 int lb=h-1,ub=t; 4 5 while(ub-lb>1) { 6 ...
阅读全文
posted @ 2015-03-19 16:24 SXISZERO
阅读(149)
评论(0)
推荐(0)
2015年3月18日
树状数组(BIT)
摘要: i的二进制的最后一个1可以通过i&(-i)得到,时间复杂度o(logn)。对于W*H的二维BIT只需要建立H个大小为x轴方向元素个数W的BIT,复杂度O(logW+logH)。同样的方法可以扩展到更高维度的情况。 1 int sum(int i) 2 { 3 int s=0; 4 w...
阅读全文
posted @ 2015-03-18 22:33 SXISZERO
阅读(164)
评论(0)
推荐(0)
2015年3月17日
素数相关算法
摘要: 1.素性测试//素性测试o(sqrt(n))1 int is_prime(int n)2 {3 for(int i=2;i*i divisor(int n) { 2 vector res; 3 for(int i=2;i*i prime_factor(int n) 2 {...
阅读全文
posted @ 2015-03-17 16:33 SXISZERO
阅读(251)
评论(0)
推荐(0)
2015年3月14日
欧几里德与扩展欧几里德算法
摘要: 转自网上大牛博客,讲的浅显易懂。原文地址:http://www.cnblogs.com/frog112111/archive/2012/08/19/2646012.html欧几里德算法欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。基本算法:设a=qb+r,其中a,b,q,r都是整数...
阅读全文
posted @ 2015-03-14 22:59 SXISZERO
阅读(207)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
···
13
下一页
公告