Advertisement
jeff69

Untitled

Mar 26th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1.  
  2.  
  3. #include <iomanip>
  4. #include <iostream>
  5. #include <functional>
  6. #include <algorithm>
  7. #include <math.h>
  8. #include <cmath>
  9. #include <string>
  10. #include <vector>
  11. #include<set>
  12. #include<map>
  13. #include <time.h>
  14. #include <fstream>
  15. using namespace std;
  16. typedef long long ll;
  17.  
  18. typedef double d;
  19. typedef long long ll;
  20.  
  21. int a[10007];
  22.  
  23. int main()
  24. {
  25. /*
  26. freopen("free.in", "r", stdin);
  27.  
  28. freopen("free.out", "w", stdout);
  29. */
  30. //memset(dp, -1, sizeof (dp));
  31. int t;
  32.  
  33. cin >> t;
  34. while (t){
  35. t--;
  36. int x, y;
  37. cin >> x >> y;
  38. int l = max(abs(x), abs(y));
  39. int h = l*(l + 1) / 2;
  40. int v = 8*h;
  41.  
  42. int ans;
  43. if (x == l &&y == -l){
  44. ans = v;
  45. }
  46. else if (x == l){
  47. ans = v - 6 * l - (l - y);
  48. }else if (y == l){
  49. ans = v - 4 * l - (l + x);
  50. }
  51. else if (x == -l){
  52. ans = v - 2 * l - (l + y);
  53. }
  54. else if (y == -l){
  55. ans = v - (l - x);
  56. }
  57. cout << ans;
  58. if(t)cout<<endl;
  59. }
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement