Bzoj 1024x768: [SCOI2009] Happy Birthday DFS

Source: Internet
Author: User

1024x768: [SCOI2009] Happy Birthday

Time Limit:20 Sec

Memory limit:256 MB

Topic Connection

http://www.lydsy.com/JudgeOnline/problem.php?id=1024

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% data, meet 1 <= x, y <= 10000; 1 <= N <= 10

Test instructions

The following:

Data range n<=10, probably not a pressure or a search.

Our direct DFS (X,Y,N) indicates that the rectangle is now x, Y, and W, and the remaining n knives are not cut.

There is a greedy, I must want to cut down even more evenly

So it would be nice to just go with DFS.

Code:

#include <cstdio>#include<cmath>#include<cstring>#include<ctime>#include<iostream>#include<algorithm>#include<Set>#include<vector>#include<sstream>#include<queue>#include<typeinfo>#include<fstream>#include<map>#include<stack>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 1000100#defineMoD 10007#defineEPS 1e-9intNum;//const int INF=0X7FFFFFFF; //нчоч╢сConst intinf=0x3f3f3f3f; inline ll read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//**************************************************************************************DoubleDfsDoubleXDoubleYDoublek) {    if(k==1)    {        returnMax (x, y)/min (x, y); }    Doubleans=inf;  for(intI=1; i<k;i++)    {        DoubleAns1=max (Dfs (x/k*i,y,i), DFS (x/k* (k-i), y,k-i)); DoubleAns2=max (Dfs (x,y/k*i,i), DFS (x,y/k* (k-i), K-i)); Ans=min (ans,min (ans1,ans2)); }    returnans;}intMain () {intX,y,n; scanf ("%d%d%d",&x,&y,&N); printf ("%.6lf\n", DFS (x*1.0, y*1.0N1.0));}

Bzoj 1024x768: [SCOI2009] Happy Birthday DFS

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.