BZOJ 1024 SCOI 2009 生日快乐 深搜
2016-02-26 10:48
375 查看
题目大意:有一块蛋糕,长为X,宽为Y。如今有n个人来分这块蛋糕,还要保证每一个人分的蛋糕的面积相等。求一种分法,使得全部的蛋糕的长边与短边的比值的最大值最小。
思路:刚拿到这个题并没有什么思路。可是定睛一看。(n <= 10),额。。能够乱搞了。。。
直接爆搜就能够水过。传三个參数,代表当前的长和宽,还有当前块须要被分成几块,然后随便乱搞就能够水过了。。
CODE:
思路:刚拿到这个题并没有什么思路。可是定睛一看。(n <= 10),额。。能够乱搞了。。。
直接爆搜就能够水过。传三个參数,代表当前的长和宽,还有当前块须要被分成几块,然后随便乱搞就能够水过了。。
CODE:
#include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <algorithm> using namespace std; int X,Y,cnt; double DFS(double x,double y,int step); int main() { cin >> X >> Y >> cnt; cout << fixed << setprecision(6) << DFS(X,Y,cnt) << endl; return 0; } double DFS(double x,double y,int step) { if(step == 1) { if(x < y) swap(x,y); return x / y; } double _x = x / step,re = 10000.0; for(int i = 1;i < step; ++i) { double temp = DFS(_x * i,y,i); temp = max(temp,DFS(x - _x * i,y,step - i)); re = min(re,temp); } double _y = y / step; for(int i = 1;i < step; ++i) { double temp = DFS(x,_y * i,i); temp = max(temp,DFS(x,y - _y * i,step - i)); re = min(re,temp); } return re; }
相关文章推荐
- 转载:Character data is represented incorrectly when the code page of the client computer differs from the code page of the database in SQL Server 2005
- Maven安装配置
- STL学习笔记(不定期更新)
- 实现Date函数属性中的format方法
- $_SERVER变量实例
- Node.js 初识
- js中变量的函数作用域和声明提前
- Java中Double型数据的加,减,乘,除
- 计算机视觉中的边缘检测
- iOS 9 学习系列: UI Testing
- JDK1.8 十大新特性详解
- java switch语句缺少break跳转之后的算法原理
- android Graphics(三):区域(Range)
- android 4.0 BLE开发官方文档
- C++返回table给lua
- Winform混合式开发框架的特点总结
- 互联网科普知识【野狗】
- Typescript学习笔记(五) 模块机制
- JAVA装饰器模式
- linux环境下,配置eclipse nodejs开发环境