fork(3) download
  1. #include <math.h>
  2. #include <stdio.h>
  3. #define MAX(x,y) (x)>(y)?(x):(y)
  4. int main(){
  5. double x=5, y=6, n=7;//values here
  6. double px=ceil(sqrt(n*x/y));
  7. double sx,sy;
  8. if(floor(px*y/x)*px<n) //does not fit, y/(x/px)=px*y/x
  9. sx=y/ceil(px*y/x);
  10. else
  11. sx= x/px;
  12. double py=ceil(sqrt(n*y/x));
  13. if(floor(py*x/y)*py<n) //does not fit
  14. sy=x/ceil(x*py/y);
  15. else
  16. sy=y/py;
  17. printf("%f",MAX(sx,sy));
  18. return 0;
  19. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
1.666667