Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdbool.h>
- double min(double a, double b)
- {
- if(a<b)
- return a;
- return b;
- }
- int main()
- {
- long a, h, w;
- scanf("%d",&a);
- scanf("%d",&h);
- scanf("%d",&w);
- double x = 10000000000;
- bool t = false;
- for (int k = 1; k * a <= h; k++)
- {
- long l = ( a * k + k * w + w - h) / (a + h);
- if (l>=0 && (h - a * k) * (l + 1) == (w - a * l) * (k + 1))
- {
- t = true;
- x = min(x, ((double)(h - a * k)) / ((double)(k + 1)));
- }
- }
- if (t)
- printf("%f",x);
- else
- printf("-1");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement