Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define gc getchar unlocked
  4. #ifndef ONLINE JUDGE
  5. #define gc getchar
  6. #endif // ONLINE JUDGE
  7.  
  8. #define pc putchar_unlocked
  9. #ifndef ONLINE JUDGE
  10. #define pc putchar
  11. #endif // ONLINE JUDGE
  12.  
  13. #define fRead freopen("input.txt","r",stdin)
  14. #define fWrite freopen ("output.txt","w",stdout)
  15.  
  16. #define eps 1e-8
  17. #define inf 0x3f3f3f3f
  18. #define INF 2e18
  19. #define LL long long
  20. #define ULL unsigned long long
  21. #define PI acos(-1.0)
  22. #define pb push_back
  23. #define mk make_pair
  24. #define pii pair<int,int>
  25. #define pLL pair<LL,LL>
  26. #define ff first
  27. #define ss second
  28. #define all(a) a.begin(),a.end()
  29. #define rall(a) a.rbegin(),a.rend()
  30. #define SQR(a) ((a)*(a))
  31. #define Unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
  32. #define min3(a,b,c) min(a,min(b,c))
  33. #define max3(a,b,c) max(a,max(b,c))
  34. #define min4(a,b,c,d) min(min(a,b),min(c,d))
  35. #define max4(a,b,c,d) max(max(a,b),max(c,d))
  36. #define Iterator(a) __typeof__(a.begin())
  37. #define rIterator(a) __typeof__(a.rbegin())
  38. #define FOR(a,it) for(Iterator(a) it = a.begin();it != a.end(); it++)
  39. #define rFOR(a,it) for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
  40.  
  41. using namespace std;
  42.  
  43. const int MOD = 1e9 + 7;
  44. int fx[] = {+1,-1,+0,+0,+1,+1,-1,-1,+0};
  45. int fy[] = {+0,+0,+1,-1,+1,-1,+1,-1,+0};
  46. template <typename T> inline T GCD (T a,T b ) {a = abs(a);b = abs(b);while ( b ) { a = a % b; swap ( a, b ); } return a;}
  47. template <typename T> inline T LCM(T x,T y){T tp = GCD(x,y);if( (x / tp) * 1. * y > 9e18) return 9e18;return (x / tp) * y;}
  48. template <typename T> inline T BigMod(T A,T B,T M){T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
  49. template <typename T> inline T InvMod (T A,T M){return BigMod(A,M-2,M);}
  50. /*---------------------------fast I/O------------------------------------*/
  51. #define scani2(a,b) scani(a) , scani(b)
  52. #define scani3(a,b,c) scani(a), scani(b), scani(c)
  53. #define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
  54. #define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
  55. template <typename T> bool scani(T &n){n = 0;bool got = false;bool negative = false;char c = gc();while( c < '0' || c > '9'){if(c == '-') negative = true;c = gc();}while(c >= '0' && c <= '9'){got = true;n = n*10 + c-48;c = gc();}if(negative) n = ~(n-1);return got;}
  56. template <typename T> void write(T n,int type = true){if(n<0) {pc('-');n = -n;}if(!n) {pc('0');if(type==32) pc(' '); else if(type) pc('\n'); return;}char buff[22];int len = 0;while(n) buff[len++] = n%10+48,n/=10;for(int i=len-1;i>=0;i--) pc(buff[i]);if(type==32) pc(' '); else if(type) pc('\n');}
  57. int scans(char *a){int i=0;char c = 0;while(c < 33) c = gc();while(c > 33){a[i++] = c;c = gc();}a[i] = 0;return i;}
  58. /*********************************************** End of template *********************************************/
  59.  
  60. int main()
  61. {
  62. int t , qq = 1;
  63. scani(t);
  64. while(t--){
  65. double x0,y0,rx,ry,px,py;
  66. scanf("%lf %lf %lf %lf %lf %lf",&x0,&y0,&ry,&rx,&px,&py);
  67. double mx,my;
  68. x0 -= px;
  69. y0 -= py;
  70. //mx = (x0 + x0 + rx) / 2 = (2 * x0 + rx) / 2;
  71. //my = (y0 + y0 + ry) / 2 = (2 * y0 + ry) / 2;
  72. mx = (2.0 * x0 + rx) * .5;
  73. my = (2.0 * y0 + ry) * .5;
  74. if(!mx && !my){
  75. mx += px;
  76. y0 += py;
  77. printf("%f %f\n%f %f\n",mx,y0,mx,y0+ry);
  78. continue;
  79. }
  80. double x1,y1,x2,y2;
  81. x1 = y0 * (mx / my);
  82. if(x0 <= x1 && x1 <= x0 + rx){
  83. x2 = (y0 + ry) * (mx / my);
  84. x1 += px;
  85. x2 += px;
  86. y0 += py;
  87. printf("%f %f\n%f %f\n",x1,y0,x2,y0+ry);
  88. }
  89. else {
  90. y1 = x0 * (my / mx);
  91. y2 = (x0 + rx) * (my / mx);
  92. x0 += px;
  93. y1 += py;
  94. y2 += py;
  95. printf("%f %f\n%f %f\n",x0,y1,x0+rx,y2);
  96. }
  97. }
  98. return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement