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






Siriuslzx

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页

2012年7月14日

poj - 3264 Balanced Lineup
摘要: 简单题,求一定范围内的最大数于最小数之差,用两个数组保存max和min就行了。 1 #include <stdio.h> 2 #include <string.h> 3 #define N 50005 4 #define INF 0x7fffffff 5 int max[4*N],min[4*N]; 6 int D; 7 int Max(int a,int b) 8 { 9 return a>b ?a :b;10 }11 int Min(int a,int b)12 {13 return a<b ?a :b;14 }15 int query(int a,in 阅读全文
posted @ 2012-07-14 00:09 Siriuslzx 阅读(139) 评论(0) 推荐(0)
 
hdu 4006 The kth great number
摘要: 这题虽然是线段树的作业,但我是用pq偷懒过的,它的思路和poj 1442差不多,但要简单。 1 #include <stdio.h> 2 #include <queue> 3 using namespace std; 4 int main() 5 { 6 int m,n,k,t,cnt; 7 char ch; 8 while(~scanf("%d%d",&m,&n)) 9 {10 cnt = 0;11 priority_queue <int> small;12 priority_queue <int, vector. 阅读全文
posted @ 2012-07-14 00:06 Siriuslzx 阅读(133) 评论(0) 推荐(0)
 
hdu 1394 Minimum Inversion Number
摘要: 求最少逆序是多少,推荐用线段树,但暴力也能过,我用的方法两者皆非。我只是用暴力求第一种排列的逆序数,剩下的用小技巧推出。 1 #include <iostream> 2 using namespace std; 3 int a[5010]; 4 int main() 5 { 6 int n,i,j,ans,min; 7 while(cin>>n) 8 { 9 for(i = 0; i < n; i++)10 cin>>a[i];11 ans = 0;12 for(i = 0; i < n-1; i+... 阅读全文
posted @ 2012-07-14 00:03 Siriuslzx 阅读(157) 评论(0) 推荐(0)
 

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)
 

2012年7月12日

poj - 3468 A Simple Problem with Integers
摘要: 今天的难度又增加了,在好不容易把练习A了以后,才发现,昨天的题根本就不叫题,我一口气刷得就剩一题了。只能说,攻克变态题的方法,就是去做更变态的题,然后原来的题就不变态了……今天的作业,我的收获是,change、pushdown等涉及数据的函数的关键内容,是要随题目变化的。 1 #include <stdio.h> 2 const int N = 100005; 3 long long sum[4*N]; 4 long long add[4*N]; 5 int D; 6 void update(int cur) 7 { 8 sum[cur] = sum[cur<<1] + 阅读全文
posted @ 2012-07-12 23:17 Siriuslzx 阅读(178) 评论(0) 推荐(0)
 

2012年7月11日

hdu 1754 I Hate It
摘要: 今天听斌哥讲课,果然V5,讲的是竞赛用堆,从基本到扩展,自顶向下和自底向上,递归与非递归……基本是听懂了,刷了两题,把顶和底都敲了一遍,都A了。本来打算把课后练习刷完的,无奈还不习惯高强度训练,做了两题以后感觉脑力枯竭了,怎么也做不下去了,唉。hdu 1754 1 #include <stdio.h> 2 #include <string.h> 3 const int MAXD = 200005; 4 int tree[4*MAXD]; 5 int D; 6 int max(int a,int b) 7 { 8 return a>b ?a :b; 9 }10 vo 阅读全文
posted @ 2012-07-11 23:29 Siriuslzx 阅读(136) 评论(0) 推荐(0)
 

2012年7月10日

poj - 1442 Black Box
摘要: 好久没刷题了,脑子都锈掉了。这题是用优先队列做的,而且是STL里的。STL里的priority_queue默认是大堆,你可以理解为递减数列。如果要用小堆需要一点参数,我只记得一个简单些的方法:priority_queue<T, vector<T>, greater<T> >,T表示数据类型,这样就是一个小堆了。做这题时我“参考”了别人的代码,不过原版的注释写得很混乱,不知道是不是用来忽悠人的。以下是代码: 1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 阅读全文
posted @ 2012-07-10 22:57 Siriuslzx 阅读(179) 评论(0) 推荐(0)
 

2012年5月10日

UVA 10154 - Weights and Measures
摘要: 这题对我来说有些难,参考了学长的代码,所以让我写“我的思路”肯定会心虚的,就把原文地址贴过来了。核心思想是用f[i]表示能叠 i 层时最轻的总重量,每次扫描的时候都会更新f[i]。这是原文:http://www.cnblogs.com/staginner/archive/2011/11/30/2268497.html代码自己改了一下,本来想把qsort改成sort的,但是毕竟很久没接触qsort了,就没做太大的改动,当作复习qsort。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h& 阅读全文
posted @ 2012-05-10 23:48 Siriuslzx 阅读(205) 评论(0) 推荐(0)
 
上一页 1 ··· 5 6 7 8 9 10 11 12 下一页