[bzoj1024] [SCOI2009] Happy Birthday (enumeration)

Source: Internet
Author: User

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 Input5 5 5Sample output1.800000hint "Data size and conventions"

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


Analysis of a rare encounter with a water problem qaq directly with DFS enumeration all the solutions to update the answer is good ...

1/**************************************************************
2 problem:1024
3User:asmdef
4language:c++
5result:accepted
6time:16 ms
7memory:804 kb
8****************************************************************/
9
Ten/***********************************************************************/
One/**********************by Asm.def-wu jiaxin*****************************/
A/***********************************************************************/
-#include <cstdio>
-#include <cstring>
the#include <cstdlib>
-#include <ctime>
-#include <cctype>
-#include <algorithm>
+#include <cmath>
-usingnamespaceStd
+#defineSetfile (x) (Freopen (#x ".", "R", stdin), Freopen (#x ". Out", "w", stdout))
A#defineGetc () GetChar ()
attemplate<classT>inlinevoidGETD (T &x) {
-Charch = getc ();BOOLNeg =false;
- while(!isdigit (CH) && ch! ='-') ch = getc ();
-if(ch = ='-') ch = getc (), neg =true;
-x = CH-'0';
- while(isdigit (ch = getc ())) x = x *Ten-'0'+ ch;
inif(neg) × =-X;
-}
to/***********************************************************************/
+
-DoubleDfsintNDoubleLDoubleS) {
theif(L < s) Swap (L, s);
*if(N = =1)returnl/s;
$DoubleMin = l/s*n, part =1.0/N, p;
Panax NotoginsengintI, n = n/2-(N &1==0);
- for(i =1; I <= n;++i) {
thep = part * I * L;
+min = min (min, max (DFS (i, S, p), DFS (N-i, S, l-p));
Ap = part * I * S;
themin = min (min, max (DFS (i, L, p), DFS (N-i, L, s-p));
+}
-if(N &1==0min = min (min, min (Dfs (i, S, L/2), DFS (i, L, S/2)));
$returnMin;
$}
-
-InlinevoidWork () {
theintX, Y, N;
-scanf"%d%d%d", &x, &y, &n);
Wuyiprintf"%.6lf\n", DFS (N, X, Y));
the}
-
WuintMain () {
-
About#ifdef DEBUG
$Freopen ("Test.txt","R", stdin);
-#elif!defined Online_judge
-Setfile (bzoj_1024);
-#endif
AWork ();
+
the#ifdef DEBUG
-printf"\n%.2lf sec \ n", (Double) clock ()/clocks_per_sec);
$#endif
thereturn0;
the}
the?Enumeration Scenarios

[bzoj1024] [SCOI2009] Happy Birthday (enumeration)

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.