• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






Siriuslzx

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

2012年7月13日

hdu 1166 敌兵布阵
摘要: 这题用了自顶向下的递归方式。 1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 const int MAXD = 50005; 5 int tree[4*MAXD]; 6 int a[MAXD],D; 7 int query(int x,int y) 8 { 9 int i=D+x-1, j=D+y+1, ans=0;10 for(; i+1 != j; i>>=1,j>>=1)11 {12 if(~i & 1)13 ans += tree[i^... 阅读全文
posted @ 2012-07-13 23:51 Siriuslzx 阅读(131) 评论(0) 推荐(0)
 
poj - 3258 River Hopscotch
摘要: 最小值最大化问题,刚开始没思路,还是经che兄提醒,用二分,然后百度之,抄了一份。不过我是个有原则的人,就算要抄,也是要先理解才行,然后手打一份。为了证明彻底理解,偶尔还会小改动一下,比如把数组从1开始改为从0开始,for循环的条件改一下等等。 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 int a[50005]; 5 int l,m,n; 6 bool ok(int mid) 7 { 8 int cnt=0,start=0,i; 9 for(i = 0; i <= n 阅读全文
posted @ 2012-07-13 23:42 Siriuslzx 阅读(140) 评论(0) 推荐(0)
 
hdu 2795 - Billboard
摘要: 第一眼看这题不知所云,现在已经能轻松分析,看样子这两天进步还是有的。这题h是10^9的,看起来有点吓人,但因为n只有20W,所以h是10^999也没用,当h很大时数据范围就被固定在n上了,这点要多谢chenan前辈的提醒。 1 #include <stdio.h> 2 #include <string.h> 3 #define N 200005 4 int tree[4*N],D; 5 int max(int a,int b) 6 { 7 return a>b ?a :b; 8 } 9 void update(int n)10 {11 for(; n^1; n & 阅读全文
posted @ 2012-07-13 22:56 Siriuslzx 阅读(162) 评论(0) 推荐(0)