Bzoj_1024_[shoi2008]_ Happy Birthday _ (Dfs)

Source: Internet
Author: User

Describe

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

Given a \ (x*y\) of the distance shape, the requirement is parallel to the edge cut, and finally cut into a n\ area equal to the small pitch, the long edge and the short edge ratio of the maximum value of the minimum value,

Analysis

Notice a property, if a distance is divided into \ (x\) parts, because this \ (x\) part of the same area, so the first knife must be proportional, rather than casually cut. So Dfs is ready.

1#include <bits/stdc++.h>2 using namespacestd;3 4 intn,x,y;5 DoubleDfsDoubleXDoubleYintN) {6     if(n==1)returnMax (x/y,y/x);7     intUp=n>>1;Doubleans=1e9;8      for(intI=1; i<=up;i++){9Ans=min (Ans,max (Dfs (x/n*i,y,i), DFS (x/n* (n-i), y,n-i)));TenAns=min (Ans,max (Dfs (x,y/n*i,i), DFS (x,y/n* (n-i), N-i))); One     } A     returnans; - } - intMain () { thescanf"%d%d%d",&x,&y,&n); -printf"%.6lf\n", DFS (x,y,n)); -     return 0; -}
View Code

1024x768: [SCOI2009] Happy Birthday time limit:1 Sec Memory limit:162 MB
submit:2264 solved:1640
[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.800000Hintsource

Bzoj_1024_[shoi2008]_ 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.