摘要: 题目链接我没看清题目用了int+四舍五入竟然搞了30次。。。三分随便从网上找了个模版。。。话说当时感觉应该是三分,可是就是这么悲剧。。#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 50001struct node{ double x; double w;} p[N];int n;double getsum(double mid){ int i; double tt,sum = 0; for(i = 0; i <= n-1; i ++) { tt = p[i].... 阅读全文
posted @ 2012-08-09 21:07 Naix_x 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题目链接找最大,这里居然会超时。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #define N 200001 5 struct node 6 { 7 int l; 8 int r; 9 int v;10 }tree[4*N];11 int max(int a,int b)12 {13 return a>b?a:b;14 }15 void build(int l,int r,int rt)16 {17 int m;18 tree[rt].l = l;19 ... 阅读全文
posted @ 2012-08-09 11:56 Naix_x 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 题目链接这个题,用完树状数组,再用线段树水过。线段树,却是感觉比树状数组的功能强多了。只要把线段树的思想理解,然后把实现过程,递归过程了解,单点更新就没问题了。#include <stdio.h>#include <string.h>#include <stdlib.h>#define N 50001struct node{ int l; int r; int v;}tree[4*N];void build(int l,int r,int rt){ int m; tree[rt].l = l; tree[rt].r = r; if(l == r) ... 阅读全文
posted @ 2012-08-09 10:45 Naix_x 阅读(143) 评论(1) 推荐(0) 编辑