No idea ......
However, because each cake has the same area and must be cut into two halves each time, the area of each half is a multiple of the area of each cake.
Calculate the number of cut-down cakes, calculate the cut place, divide X and Y, and perform recursive search.
Code:
#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>#include <cmath>#define inf 0x7f7f7f7fusing namespace std;int num;double X, Y;double dfs(int n, double x, double y){ if (n == 1) return max(x, y) / min(x, y); double d = (double)n; double ans = inf; for (int i = 1; i < n; ++i) { ans = min(ans, max(dfs(i, x/d*i, y), dfs(n-i, x/d*(n-i), y))); ans = min(ans, max(dfs(i, x, y/d*i), dfs(n-i, x, y/d*(n-i)))); } return ans;}int main(){ scanf("%lf%lf%d", &X, &Y, &num); printf("%lf\n", dfs(num, X, Y)); return 0;}
Bzoj 1024 Happy Birthday scoi2009