bzoj1024: [SCOI2009] Happy Birthday

Source: Internet
Author: User
Topic links

bzoj1024 Topic description Description

Windy's birthday, in order to celebrate his birthday, his friends helped him to buy a side length of X and Y, respectively, a rectangular cake. Now including windy, there are a total of N people to divide the big cake, asking everyone to get the same area of cake. Windy Solo, everything can only be parallel to one side of the cake (either side), and must be cut into two pieces of this piece of cake. In this way, to cut into n pieces of cake, windy must cut N-1 times. To make every piece of cake look beautiful, we require that the maximum value of the long and short sides of the N-piece cake be the smallest. Can you help windy to find out the ratio? Input

Contains three integers, X Y N. Output

Contains a floating-point number that retains 6 decimal places. Sample Input

5 5 5 Sample Output

1.800000 HINT

100% of the data, meet 1 <= x, y <= 10000; 1 <= N <= 10. Solving

Nothing to say, the search can be.

 #include <cstdio> #include <cstring> #include <iostream> #include <
algorithm> #include <cmath> #include <queue> #include <vector> using namespace std;
int n,x,y;
    Double Dfs (double x,double y,int N) {if (n==1) return max (x, y)/min (x, y);
    Double ans=1000000007;
        for (int i=1;i<n;i++) {ans=min (Ans,max (Dfs (x,y/n*i,i), DFS (x,y-y/n*i,n-i)));
    Ans=min (Ans,max (Dfs (x/n*i,y,i), DFS (x-x/n*i,y,n-i)));
} return ans;
    } int main () {scanf ("%d%d%d", &x,&y,&n); 
    printf ("%.6f\n", DFS (X,y,n));
return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.