当前位置: 首页 > news >正文

福田祥菱v3报价及图片/北京培训seo哪个好

福田祥菱v3报价及图片,北京培训seo哪个好,广西短视频运营是,软件开发接单平台排行求n个矩阵面积相交的部分,和求面积并一样,不过这里需要开两个数组保存覆盖一次和覆盖两次以上的次数的部分,还是模板,主要注意点就是pushup部分,如果我已经被两次覆盖,那我的两个数组在这个root点的宽度就可…

  求n个矩阵面积相交的部分,和求面积并一样,不过这里需要开两个数组保存覆盖一次和覆盖两次以上的次数的部分,还是模板,主要注意点就是pushup部分,如果我已经被两次覆盖,那我的两个数组在这个root点的宽度就可以直接算了,如果我被一次覆盖,那么我一个覆盖的部分可以直接计算,两次覆盖的部分取决于sum1数组,如果我不是一个线段,那就是0,如果我是一个线段,那么我就是由左边区间覆盖一次和右边区间覆盖一次相加得来。如果我这个区间现在没有被覆盖到,那么我的两个数组都是由各自部分的区间和得来的

#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define first fi
#define second se
#define lowbit(x) (x & (-x))typedef unsigned long long int ull;
typedef long long int ll;
const double pi = 4.0*atan(1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 2005;
const int maxm = 305;
using namespace std;int n, m, tol, T;
struct Node{double l, r, h;int f;bool operator < (Node a) const {return h < a.h;}
};
Node node[maxn];
double a[maxn];
int cnt[maxn << 2];
double sum1[maxn << 2];
double sum2[maxn << 2];void init() {memset(a, 0, sizeof a);memset(cnt, 0, sizeof cnt);memset(sum1, 0, sizeof sum1);memset(sum2, 0, sizeof sum2);memset(node, 0, sizeof node);
}void pushup(int left, int right, int root) {if(cnt[root] >= 2) {sum2[root] = sum1[root] = a[right+1] - a[left];} else if(cnt[root] == 1) {sum1[root] = a[right+1] - a[left];if(left == right)    sum2[root] = 0;else    sum2[root] = sum1[root << 1] + sum1[root << 1 | 1];} else {if(left == right)    sum1[root] = sum2[root] = 0;else {sum1[root] = sum1[root << 1] + sum1[root << 1 | 1];sum2[root] = sum2[root << 1] + sum2[root << 1 | 1];}}
}void update(int left, int right, int prel, int prer, int val, int root) {if(prel <= left && right <= prer) {cnt[root] += val;pushup(left, right, root);return ;}int mid = (left + right) >> 1;if(prel <= mid)    update(left, mid, prel, prer, val, root << 1);if(prer > mid)    update(mid+1, right, prel, prer, val, root << 1 | 1);pushup(left, right, root);return ;
}int main() {scanf("%d", &T);while(T--) {init();scanf("%d", &n);double x1, y1, x2, y2;for(int i=1; i<=n; i++) {scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);node[2*i].l = node[2*i-1].l = x1;node[2*i].r = node[2*i-1].r = x2;node[2*i].h = y1, node[2*i-1].h = y2;node[2*i].f = 1, node[2*i-1].f = -1;a[2*i] = x1, a[2*i-1] = x2;}n <<= 1;sort(node+1, node+1+n);sort(a+1, a+1+n);int nn = unique(a+1, a+1+n) - (a+1);double ans = 0.0;for(int i=1; i<n; i++) {int l = lower_bound(a+1, a+1+nn, node[i].l) - a;int r = lower_bound(a+1, a+1+nn, node[i].r) - a;update(1, nn, l, r-1, node[i].f, 1);ans += sum2[1] * (node[i+1].h - node[i].h);}printf("%.2f\n", ans);}return 0;
}
View Code

 

转载于:https://www.cnblogs.com/Jiaaaaaaaqi/p/9356978.html

http://www.jmfq.cn/news/4775527.html

相关文章:

  • 网站模板免费/steam交易链接在哪里看
  • 济南网站推广¥做下拉去118cr/怎么制作一个网页
  • 青山做网站/微信小程序开发文档
  • 高州网站建设/seo技术平台
  • 虚拟机中做网站/泉州百度推广排名优化
  • 网站增加权重/最知名的网站推广公司
  • 建站节/网站模板及源码
  • wordpress建论坛/上海百度seo牛巨微
  • 做配电柜在哪个网站发布信息/百度大全
  • 深圳CSS3网站建设价格/会计培训班需要学多长时间
  • 网站推广公司排名/seo引擎优化培训
  • 网站开发项目企划书/网站搭建关键词排名
  • 济南网站建设小程序/百家号关键词seo优化
  • 手机网站如何制作免费/一个新品牌如何推广
  • 长沙哪里可以做网站/百度关键词排名查询
  • 宝鸡品牌网站建设/seo全网推广营销软件
  • 新闻类网站开发难点/鸡西seo
  • php做网站用html做吗/下载安装百度
  • 几十万做网站平台/seo搜狗
  • 泰兴网站建设吧/qq群推广引流免费网站
  • 长春网络营销/西安seo外包
  • 货物运输东莞网站建设/怎样创建网页
  • 上海市青浦区建设局网站/品牌营销策略有哪些
  • 专门做资产负债表结构分析的网站/企业网络营销推广方案策划范文
  • 集团网站建设工作方案/网络优化的内容包括哪些
  • 网页设计与网站建设实训报告/腾讯广告代理商加盟
  • 沈阳房地产网站开发/手机维修培训班学校
  • 301网站目录/百度搜索入口网址
  • 网站现在用h5做的吗/没干过网络推广能干吗
  • 做网站开发的步骤/英文外链平台