fork download
  1. #include <cstring>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <iostream>
  7. #include <fstream>
  8. #include <queue>
  9.  
  10. #define rep(i, l, r) for(int i = l; i <= r; i++)
  11. #define down(i, l, r) for(int i = l; i >= r; i--)
  12. #define MS 34567
  13. #define MAX 1037471823
  14.  
  15. using namespace std;
  16.  
  17. double x, y;
  18. int n;
  19.  
  20. double Search(double x, double y, int n)
  21. {
  22. double a, b;
  23.  
  24. if (x > y) a = x, x = y, y = a;
  25. if (n == 1) return y / x;
  26. b = MAX;
  27. a = y / n;
  28. rep(i, 1, n-1)
  29. b = min(b, max(Search(x, a*i, i), Search(x, y-a*i, n-i)));
  30. a = x / n;
  31. rep(i, 1, n-1)
  32. b = min(b, max(Search(y, a*i, i), Search(y, x-a*i, n-i)));
  33. return b;
  34. }
  35.  
  36. int main()
  37. {
  38. scanf("%lf%lf%d", &x, &y, &n);
  39. printf("%.6lf\n", Search(x, y, n));
  40. return 0;
  41. }
Success #stdin #stdout 0.05s 3300KB
stdin
54 32 10
stdout
1.481481