- 博客(37)
- 资源 (4)
- 收藏
- 关注
原创 hdu_5150 水
交个题证明我还活着#include#include#include#includeusing namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF) { int sum=0; int a; for(int i=0;i<n;i++){
2015-01-02 16:16:56 441
原创 hdu_2871
#include#include#include#include#include#include#define lson r,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=55555;using namespace std;int lsum[maxn<<2],rsum[rt<<2],sum[rt<<2];void pushUp
2014-11-14 09:42:09 425
原创 poj_3468,线段树成段更新
参考自http://www.notonlysuccess.com/index.php/segment-tree-complete/
2014-09-13 20:52:26 356
原创 hdu_2795,线段树,单点更新
#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=222222;int seq[maxn<<2];int h,w;void pushUp(int rt){ seq[rt]=max(seq[rt<<1],seq
2014-09-12 07:43:56 410
原创 hdu_1394,线段树求逆序数
http://www.notonlysuccess.com/index.php/segment-tree-complete/#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=5555;int sum[ma
2014-09-11 20:02:25 422
原创 hdu_1754,线段树单点更新,求区间最值
http://www.notonlysuccess.com/index.php/segment-tree-complete/#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define maxn 2222222using namespace std;int a[maxn
2014-09-10 17:51:46 452
原创 hdu_1166,线段树单点更新
在刷线段树,参考自http://www.notonlysuccess.com/index.php/segment-tree-complete/
2014-09-10 12:22:07 437
原创 poj_1195Mobile phones,二维树状数组
#include#include#include#includeusing namespace std;int a[1300][1300];int s;int lowbit(int x){ return x&(-x);}void add(int x,int y,int d){ for(int i=x;i<=s;i+=lowbit(i)) for(int
2014-09-05 20:11:16 393
原创 poj_2299Ultra-QuickSort,树状数组离散化
求逆序数#include#include#include#includeusing namespace std;struct node{ int num; int pos;};node st[500010];int reflect[500010];int a[500010];int n;bool cmp(node a,node b){ return
2014-09-04 22:14:39 424
原创 uva_11997,K Smallest Sums优先队列
#include#include#include#include#includeusing namespace std;int a[1000][1000];int n;struct Item{ int jx,sum; bool operator < (const Item& a)const{ return sum>a.sum; }};v
2014-09-03 17:50:22 408
原创 LA_3135优先队列
#include #include #include #include using namespace std;struct st{ int QNum,Period,time; bool operator < (const st& a) const{ return time>a.time||(time==a.time&&QNum>a.QNum); }
2014-09-03 13:21:48 341
原创 uva_127,栈以及vector的应用
参考自http://www.cnblogs.com/maqiang/archive/2012/05/02/2479760.html
2014-09-02 14:12:13 431
原创 poj_1974,最长回文字串manacher
时间复杂度为O(n),参考:http://bbs.dlut.edu.cn/bbstcon.php?board=Competition&gid=23474#include#include#include#include#define maxn 2001000using namespace std;char s[maxn],st[maxn];int p[maxn];int cases=
2014-08-23 12:21:24 457
原创 hdu_4430,二分
注意处理溢出#include#include#include#includeusing namespace std;long long n;long long a[60][2];int k;int fun(long long y,int x){ long long cnt=0,cur=1; for(int i=1; i<=x; i++) {
2014-08-21 17:33:51 357
原创 求凸包面积
#include#include#include#include#includeusing namespace std;struct Point{ double x,y; Point(double x=0,double y=0):x(x),y(y){}};typedef Point Vector;bool cmp_x(const Point &p,const Po
2014-08-21 14:00:53 446
原创 poj_2187求凸包直径
#include#include#include#include#includeusing namespace std;struct Point{ int x,y; Point(int x=0,int y=0):x(x),y(y){}};typedef Point Vector;bool cmp(const Point &p,const Point &q){
2014-08-21 13:58:32 404
原创 几何,求两整数点确定的线段上的整数点的个数
#include#include#include#include#includeusing namespace std;int gcd(int a,int b){ return a%b==0?b:gcd(b,a%b);}int main(){ int x1,x2,y1,y2; while(cin>>x1>>y1>>x2>>y2) {
2014-08-21 12:25:15 1035
原创 zoj_3657,12年长春站c题,模拟
#include#include#include#includeusing namespace std;int main(){ int n; int a[6]; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%d",&a[i]);
2014-08-18 21:47:02 368
原创 poj_2187凸包,暴力解法
#include#include#include#include#includeusing namespace std;struct Point{ int x,y; Point(int x=0,int y=0):x(x),y(y){}};typedef Point Vector;bool cmp(const Point &p,const Point &q){
2014-08-11 10:03:16 427
原创 zoj_3735,dp,长沙站j题
#include#include#include#includeusing namespace std;double a[10010][150];double dp[10010][150];int b[10010];int n;void solve(int cnt){ memset(dp,0,sizeof(dp)); for(int i=0;i<cnt;i++)
2014-08-10 07:37:03 363
原创 hdu_1698线段树成段更新
#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;const int maxn=100100;int sum[maxn<<2],col[maxn<<2];void pushUP(int rt){ sum[rt]=sum[r
2014-08-09 19:58:49 382
原创 poj_2828线段树,逆序插入
#include#include#include#include#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn = 200020;using namespace std;int p[200020],v[200020];int sum[maxn<<2];int ans[maxn];void build
2014-08-09 12:50:05 371
原创 poj_3071概率dp
确定好对手就简单了。#include#include#include#includeusing namespace std;double a[150][150];double dp[9][150];int n;void solve(){ memset(dp,0,sizeof(dp)); for(int i=0;i<=(1<<n);i++) dp[0
2014-08-06 22:28:50 359
转载 poj_1185状压dp
用二维数组写了好久,失败啊。。#include#include#include#includeusing namespace std;int n,m;int dp[110][110][110];char st[110][12];int s[110],an[110],as[110];int convert(int n){ int cnt=0; while(n>0)
2014-05-28 21:21:06 624
转载 poj_3468线段树成段更新求区间和
#include#include#includelong long num[100010];using namespace std;struct st{ int l; int r; long long sum; long long a;} p[400100];void build(int t,int l,int r){ p[t].l=l;
2014-05-20 14:21:08 546
原创 uva_644暴力加字典树解法
暴力#include#include#includeusing namespace std;int main(){ int t=0,i=0; char s[10][12]; bool a[12][12]; memset(s,'\0',sizeof(s)); while(scanf("%s",s[i])!=EOF) { if(
2014-05-05 20:36:02 483
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人