设为首页 加入收藏

TOP

Hdu 5032 Always Cook Mushroom (树状数组)
2015-07-20 17:36:59 来源: 作者: 【 】 浏览:2
Tags:Hdu 5032 Always Cook Mushroom

题目大意:

在一个1000*1000的二维平面上,每一个整点都有一个权值,权值大小是 the production in the grid points (x, y) is (x + A)(y + B) where A, B are two constant.


思路分析:

先离线处理出所有的询问,对于每一个询问都有一个极角,按照极角排序。

然后对于平面上每一个点,都依次的加入到BIT中,当当前的这个询问的极角比这个点到原点的对应极角要大的时候,就将这个点加进去。

可以理解成有一根线,按照逆时针的方向在扫描整个二维平面,当这根线和某一个询问重合的时候,记录和,否则将扫过的所有点加入到BIT中。


#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #define lowbit(x) (x&(-x)) #define maxn 1005 using namespace std; typedef long long ll; int A,B; struct node { int r,c; double p; node(){} node(int _r,int _c,double _p):r(_r),c(_c),p(_p){} bool operator < (const node &cmp)const { return p
       
         cq; struct line { int x,id; ll ans; double p; line(){} line(int _x,double _p):x(_x),p(_p){} bool operator < (const line &cmp)const { return p
        
          scline; ll bit[1005]; bool cmp_id(line a,line b) { return a.id
         
          =1;x-=lowbit(x))res+=bit[x]; ll ret=0; for(int x=l-1;x>=1;x-=lowbit(x))ret+=bit[x]; return res-ret; } int main() { int T,cas=1; cq.clear(); for(int i=1;i<=1000;i++) { for(int j=1;j<=1000;j++) { cq.push_back(node(i,j,1.0*i/j)); } } sort(cq.begin(),cq.end()); for(scanf("%d",&T);T--;) { scanf("%d%d",&A,&B); scline.clear(); int n; scanf("%d",&n); for(int i=0;i
          
           

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 1064 Cable master(很好玩的.. 下一篇C++之如何实现一个不能被继承的类

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)