Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- double mx(double a, double b)
- {
- if (a > b)
- return a;
- return b;
- }
- double mn(double a, double b)
- {
- if (a < b)
- return a;
- return b;
- }
- int main(void)
- {
- double a, b, c, d;
- scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
- double OX, OY;
- OX = (double)(b) / 2;
- OY = (double)(a) / 2;
- double d2 = c * c + d * d;
- double r2 = d2 / 4;
- //Finding cross b
- double D1 = -4 * (a * a - 2 * a * OY + OY * OY - r2);
- double sqrtD1;
- for (int i = 0; i * i <= D1; ++i)
- sqrtD1 = i;
- double xb1 = (2 * OX + sqrtD1) / 2;
- double xb2 = (2 * OX - sqrtD1) / 2;
- //finding cross a
- double D2 = -4 * (OX * OX - r2);
- double sqrtD2;
- for (int i = 0; i * i <= D2 * D2; ++i)
- sqrtD2 = i;
- double xa1 = (2 * OY + sqrtD2) / 2;
- double xa2 = (2 * OY - sqrtD2) / 2;
- if (D1 <= 0 && D2 <= 0)
- printf("YES");
- else
- if (D1 > 0 && D2 > 0)
- {
- double cbm = mn(xb1, xb2);
- if (cbm < 0 || cbm > b)
- cbm = mx(xb1, xb2);
- if (cbm < 0 || cbm > b)
- printf("NO");
- else
- {
- double cam = mn(xa1, xa2);
- if (cam < 0 || cam > a)
- cam = mx(xa1, xa2);
- if (cam < 0 || cam > a)
- printf("NO");
- else
- if (cam * cam + cbm * cbm >= c)
- printf("YES");
- else
- printf("NO");
- }
- }
- else
- if (D1 > 0 && (0 <= xb1 && xb1 <= b) && (0 <= xb2 && xb2 <= b) && (mx(xb1, xb2) - mn(xb1, xb2) >= d))
- printf("YES");
- else
- if (D2 > 0 && (0 <= xa1 && xa1 <= a) && (0 <= xa2 && xa2 <= a) && (mx(xa1, xa2) - mn(xa1, xa2) >= c))
- printf("YES");
- else
- printf("NO");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment