Advertisement
royalsflush

Referência para NSTEPS (Luiza)

Mar 2nd, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <map>
  3. using namespace std;
  4.  
  5. #define MAXL 100000
  6. map< pair<int,int>, int> m;
  7. int n;
  8. int px=0,py=0;
  9. int add[4][2] = {{1,1}, {1,-1},
  10.         {1,1}, {-1,1}};
  11.  
  12. int main() {
  13.     m[make_pair(0,0)]=0;
  14.  
  15.     for (int i=0; i<MAXL; i++) {
  16.         px+=add[i%4][0];
  17.         py+=add[i%4][1];
  18.  
  19.         m[make_pair(px,py)]=i+1;
  20.     }
  21.  
  22.     scanf("%d", &n);   
  23.    
  24.     while (n--) {
  25.         int x,y;
  26.         scanf("%d %d", &x,&y);
  27.        
  28.         if (m.find(make_pair(x,y))==m.end()) printf("No Number\n");
  29.         else printf("%d\n", m[make_pair(x,y)]);
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement