bzoj1024: [SCOI2009] Happy Birthday

Source: Internet
Author: User

The Storm! So far I'm still not searching!

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace STD; #define REP (I,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) #define CLR (x,c) memset (X,c, sizeof (x)) double mins (double &a,double b) {    if (a>b) a=b;} Double Dfs (double x,double y,int cnt) {    if (cnt==1) return Max (y/x,x/y);    Double ans=100000.0;    Rep (i,1, (cnt>>1)) {        mins (Ans,max (DFS (x*i/cnt,y,i), DFS (x* (cnt-i)/cnt,y,cnt-i));        mins (Ans,max (DFS (x,y*i/cnt,i), DFS (x,y* (cnt-i)/cnt,cnt-i)));    }    return ans;} int main () {    double x,y;int cnt;    scanf ("%lf%lf%d", &x,&y,&cnt);    printf ("%.6lf\n", DFS (X,Y,CNT));    return 0;}

  

1024x768: [SCOI2009] Happy Birthday time limit:1 Sec Memory limit:162 MB
submit:2327 solved:1689
[Submit] [Status] [Discuss] 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 includes windy
, there are a total of N people to divide this big cake, require everyone to get the same area of cake. Windy Solo, everything can only be parallel to a piece of cake
Side (on either side) and must cut the cake into two pieces. In this way, to cut into n pieces of cake, windy must cut N-1 times. To make
Each cake looks beautiful, we require the maximum value of the ratio of the long and short sides of the N-piece cake to the smallest. Can you help windy to find out the ratio?

Input

Contains three integers, X Y N. 1 <= x, y <= 10000; 1 <= N <= 10

Output

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

Sample Input5 5 5Sample Output1.800000HINT Source [Submit] [Status] [Discuss]

bzoj1024: [SCOI2009] Happy Birthday

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.