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

果然现在弱到连搜索都不会了么。。。。。

一直想二分。。。但是无论如何也推不出怎么划分。。。

QAQ

然后暴力搜索每一次割的时候左边右边各有几块或者上边下边各有几块就行了QAQ

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cmath>
  4. #include <string>
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <queue>
  8. #include <set>
  9. #include <map>
  10. using namespace std;
  11. typedef long long ll;
  12. #define pii pair<int, int>
  13. #define mkpii make_pair<int, int>
  14. #define pdi pair<double, int>
  15. #define mkpdi make_pair<double, int>
  16. #define pli pair<ll, int>
  17. #define mkpli make_pair<ll, int>
  18. #define rep(i, n) for(int i=0; i<(n); ++i)
  19. #define for1(i,a,n) for(int i=(a);i<=(n);++i)
  20. #define for2(i,a,n) for(int i=(a);i<(n);++i)
  21. #define for3(i,a,n) for(int i=(a);i>=(n);--i)
  22. #define for4(i,a,n) for(int i=(a);i>(n);--i)
  23. #define CC(i,a) memset(i,a,sizeof(i))
  24. #define read(a) a=getint()
  25. #define print(a) printf("%d", a)
  26. #define dbg(x) cout << (#x) << " = " << (x) << endl
  27. #define error(x) (!(x)?puts("error"):0)
  28. #define printarr2(a, b, c) for1(_, 1, b) { for1(__, 1, c) cout << a[_][__]; cout << endl; }
  29. #define printarr1(a, b) for1(_, 1, b) cout << a[_] << '\t'; cout << endl
  30. inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
  31.  
  32. double dfs(double x, double y, int n) {
  33. if(n==1) return max(y/x, x/y);
  34. double ret=1e99;
  35. for1(i, 1, n>>1) {
  36. ret=min(ret, max(dfs(x/n*i, y, i), dfs(x/n*(n-i), y, n-i)));
  37. ret=min(ret, max(dfs(x, y/n*i, i), dfs(x, y/n*(n-i), n-i)));
  38. }
  39. return ret;
  40. }
  41.  
  42. int main() {
  43. int x=getint(), y=getint(), n=getint();
  44. printf("%.6f", dfs(x, y, n));
  45. return 0;
  46. }

  


Description

windy的生日到了,为了庆祝生日,他的朋友们帮他买了一个边长分别为 X 和 Y 的矩形蛋糕。现在包括windy,一共有 N 个人来分这块大蛋糕,要求每个人必须获得相同面积的蛋糕。 windy主刀,每一切只能平行于一块蛋糕的一边(任意一边),并且必须把这块蛋糕切成两块。这样,要切成 N 块蛋糕,windy必须切 N-1 次。为了使得每块蛋糕看起来漂亮,我们要求 N 块蛋糕的长边与短边的比值的最大值最小。你能帮助windy求出这个比值么?

Input

包含三个整数,X Y N。

Output

包含一个浮点数,保留6位小数。

Sample Input

5 5 5

Sample Output

1.800000

HINT

【数据规模和约定】

100%的数据,满足 1 <= X,Y <= 10000 ; 1 <= N <= 10 。

Source

【BZOJ】1024: [SCOI2009]生日快乐(dfs)的更多相关文章

  1. BZOJ 1024: [SCOI2009]生日快乐 dfs

    1024: [SCOI2009]生日快乐 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/p ...

  2. BZOJ 1024 [SCOI2009]生日快乐 (搜索)

    1024: [SCOI2009]生日快乐 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3025  Solved: 2201[Submit][Statu ...

  3. BZOJ 1024: [SCOI2009]生日快乐

    Description 将一个 \(x\times y\) 的矩形分成 \(n\) 块,让最长边:最短边 最小. Sol 搜索. \(n\) 只有 \(10\) 写一个类似于记搜的东西就好了. Cod ...

  4. bzoj 1024 [SCOI2009]生日快乐——模拟

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1024 可以枚举这边放多少块.那边放多少块. 注意精度.不要每次用x*y/base算有多少块, ...

  5. BZOJ.1024.[SCOI2009]生日快乐(记忆化搜索)

    题目链接 搜索,枚举切的n-1刀. 对于长n宽m要切x刀,可以划分为若干个 长n'宽m'要切x'刀 的子问题,对所有子问题的答案取max 对所有子问题的方案取min 就是当前状态答案. 这显然是会有很 ...

  6. BZOJ 1024 SCOI2009 生日快乐 暴搜

    思路:eng...按照题意搜就好了 (一定要注意题面的n<=10--) 枚举断点...反正n<=10不怂 //By SiriusRen #include <cstdio> #i ...

  7. BZOJ 1023 [SCOI2009]生日快乐

    1024: [SCOI2009]生日快乐 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 1729  Solved: 1219[Submit][Statu ...

  8. 1024: [SCOI2009]生日快乐 - BZOJ

    Description windy的生日到了,为了庆祝生日,他的朋友们帮他买了一个边长分别为 X 和 Y 的矩形蛋糕.现在包括windy,一共有 N 个人来分这块大蛋糕,要求每个人必须获得相同面积的蛋 ...

  9. 1024: [SCOI2009]生日快乐

    暴力题,N<=10,没注意到平均分,读题真是.. 我们对于一个矩形分成两块进行搜.然后求较大值. ans=min(ans,max(dfs(x,y/n*i,i),dfs(x,y/n*(n-i),n ...

随机推荐

  1. QtGui.QComboBox

    The QtGui.QComboBox is a widget that allows a user to choose from a list of options. #!/usr/bin/pyth ...

  2. input 禁止 复制 粘贴 剪切 操作

    1.代码 <Input onCopy={(e)=>{ // 禁止拷贝 e.preventDefault(); }} onPaste={(e)=>{ // 禁止粘贴 e.prevent ...

  3. 升级Eclipse出错的解决办法“Updating Software” has encountered a problem: An error occurred while uninstalling

    运行 eclipse 把 eclipse exe 修改为 eclipse.exe.back 再运行 updates 升级成功

  4. Android中涉及到的焦点问题,focusable,clickable,enabled

    先摘抄下stackoverflow上一个启示了我的回答: try by Changing your code as: private OnClickListener saveButtonListene ...

  5. Ant—怎样Windows操作系统中搭建Apache Ant环境

    介绍一下怎样在Windows操作系统中搭建Apache Ant环境: 一.下载Apache Ant压缩文件:http://download.csdn.net/detail/wangshuxuncom/ ...

  6. spring mvc相关问题

    1: 基于注解的SpringMVC简单介绍 2: spring组件扫描<context:component-scan/>使用详解 3: springMvc 注解配置例子

  7. Using AutoFac

    第一次整理了下关于autofac的一些具体的用法 1. 安装 Autofac: Install-Package Autofac -Version 4.8.1 2. 创建两个类库项目,IService ...

  8. Windows快捷键命令

    1. 新建一个文件夹: Ctrl + shift + N; 2. Windows 查看端口信息: 1.进入cmd窗口; 2.netstat -ano : 列出所有端口的情况.在列表中我们观察被占用的端 ...

  9. 三维模型 DAE 导出格式结合 OpenGLES 要素浅析

    三维模型 DAE 导出格式结合 OpenGLES 要素浅析 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致&quo ...

  10. OpenSAML2.X 在SSO系统中的应用

    背景 年底的时候有机会开发一个SPA(单页面应用)的项目,那时候须要用到票据的方式能够用Cookie的方式来登录.当是想到了OpenID或者是CAS的方式来做统一认证中心.后来一个安全界的大牛推荐让我 ...