POJ 1195 Mobile Phones "two-dimensional tree-like array"

Source: Internet
Author: User

Test instructions: The underlying two-dimensional array, note that 0 + lowbit (0) will fall into an infinite loop-----

Before doing a one-dimensional has been tle, is because of this--------------------------

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A  -typedefLong LongLL; - Const intINF = (1<< -)-1; the Const intMod=1000000007; - Const intmaxn=1000005; -  - intc[1055][1055]; + intN; -  + intLowbit (intx) {returnX & (-x);} A  at intSumintXinty) { -     intRET =0, y1; -      while(X >0){ -Y1 =y; -          while(Y1 >0){ -RET + = c[x][y1];y1-=lowbit (y1); in         } -x-=lowbit (x); to     } +     returnret; - } the  * voidAddintXintYintd) { $     intY1;Panax Notoginseng      while(x <=N) { -Y1 =y; the          while(Y1 <=N) { +C[X][Y1] + = D; Y1 + =lowbit (y1); A         } theX + =lowbit (x); +     } - } $  $ intMain () { -     intcmd; -      while(SCANF ("%d%d", &cmd,&n)! =EOF) { theMemset (c,0,sizeof(c)); -          while(SCANF ("%d", &cmd)! = EOF && cmd! =3){Wuyi             if(cmd = =1){ the                 intx,y,d; -scanf" %d%d%d", &x,&y,&d); x++;y++; Wu Add (x,y,d); -             } About             Else{ $                 intX,y,xx,yy; -                 intRET =0; -scanf"%d %d%d%d",&x,&y,&xx,&yy); -x++;y++;xx++;yy++; Aret = SUM (xx,yy)-SUM (X-1, yy)-sum (xx,y-1) + SUM (x1, Y1); +printf"%d\n", ret); the             } -         } $     } the     return 0; the}
View Code

Say a few days didn't write the code of said AH----

Come on (^ω^).

Goooooooooooooooooo----

POJ 1195 Mobile Phones "two-dimensional tree-like array"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.