Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int rsq(int x, int y){
- int y1;
- int x1 = x;
- int sumaux = 0;
- for (; x1; x1-= x1&(-x1)){
- y1 = y;
- for(; y1; y1 -= y1&(-y1)){
- sumaux += matrix[x1][y1];
- }
- }
- return sumaux;
- }
- int rsq(int x, int y, int x2, int y2){
- int y1;
- int x1 = x2;
- int sumaux = 0;
- for (; x1; x1-= x1&(-x1)){
- y1 = y;
- for(; y1; y1 -= y1&(-y1)){
- sumaux += matrix[x1][y1];
- }
- }
- return sumaux - ((x == 1 ||y == 1) ? 0 : rsq(x-1, y-1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement