bzoj1024题解
【解题思路】
爆搜,状态f(r,x,y)表示剩下r刀,边长为x和y,对于每个状态枚举切成两块后的长度比或宽度比。复杂度o((n/2)n)。
【参考代码】
#include <algorithm>
#include <cstdio>
#define REP(I,start,end) for(int I=(start);I<=(end);I++)
#define PER(I,start,end) for(int I=(start);I>=(end);I--)
#define REPs(I,start,end,step) for(int I=(start);I<=(end);I+=(step))
#define PERs(I,start,end,step) for(int I=(start);I>=(end);I-=(step))
#define maxint 32767
#define maxlongint 2147483647
#define maxint64 9223372036854775807ll
using namespace std;
typedef unsigned short US;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;
inline int getint()
{
char ch=getchar();
while((ch<''||ch>'')&&ch!='-')
ch=getchar();
int result=;
bool impositive=ch=='-';
if(impositive)
ch=getchar();
while(ch>=''&&ch<='')
{
result=(result<<)+(result<<)+ch-'';
ch=getchar();
}
return impositive?-result:result;
}
inline int putint(int n)
{
int result=;
char* sav=new char[];
bool impositive=n<;
if(impositive)
{
putchar('-');
n=-n;
}
sav[]=n%+'';
while(n/=)
sav[result++]=n%+'';
PER(i,result-,)
putchar(sav[i]);
delete []sav;
return result+impositive;
}
inline LL getLL()
{
char ch=getchar();
while((ch<''||ch>'')&&ch!='-')
ch=getchar();
LL result=0ll;
bool impositive=ch=='-';
if(impositive)
ch=getchar();
while(ch>=''&&ch<='')
{
result=(result<<)+(result<<)+ch-'';
ch=getchar();
}
return impositive?-result:result;
}
inline int putLL(LL n)
{
int result=;
char* sav=new char[];
bool impositive=n<;
if(impositive)
{
putchar('-');
n=-n;
}
sav[]=n%+'';
while(n/=)
sav[result++]=n%+'';
PER(i,result-,)
putchar(sav[i]);
delete []sav;
return result+impositive;
}
template<typename integer> inline int read_int(integer &n)
{
char ch=getchar();
while((ch<''||ch>'')&&ch!='-')
ch=getchar();
int result=n=integer();
bool impositive=ch=='-';
if(impositive)
ch=getchar();
while(ch>=''&&ch<='')
{
n=(n<<)+(n<<)+integer(ch-'');
result++;
ch=getchar();
}
if(impositive)
{
n=-n;
result++;
}
return result;
}
template<typename integer> inline int write_int(integer n)
{
int result=;
char* sav=new char[];
bool impositive=n<;
if(impositive)
{
putchar('-');
n=-n;
}
sav[]=n%+'';
while(n/=)
sav[result++]=n%+'';
PER(i,result-,)
putchar(sav[i]);
delete []sav;
return result+impositive;
}
template<typename T> inline bool getmin(T &target,T pattern)
{
bool can=pattern<target;
if(can)
target=pattern;
return can;
}
template<typename T> inline bool getmax(T &target,T pattern)
{
bool can=pattern>target;
if(can)
target=pattern;
return can;
}
//==========================================Header Template================================================
#include <iomanip>
#include <iostream>
double DFS(int rest,double _x,double _y)
{
if(rest==)
return _x>_y?_x/_y:_y/_x;
double result=maxlongint;
REP(i,,rest>>)
{
long double x0=_x/rest,y0=_y/rest,_r=rest-i;
getmin(result,min(max(DFS(i,x0*i,_y),DFS(_r,x0*_r,_y)),max(DFS(i,_x,y0*i),DFS(_r,_x,y0*_r))));
}
return result;
}
int main()
{
int x=getint(),y=getint(),n=getint();
cout<<setiosflags(ios::fixed)<<setprecision()<<DFS(n,x,y)<<endl;
return ;
}
bzoj1024题解的更多相关文章
- 【BZOJ1024】[SCOI2009]生日快乐(搜索)
[BZOJ1024][SCOI2009]生日快乐(搜索) 题面 BZOJ 洛谷 题解 看到这个数据范围就感觉是爆搜.我们爆搜左右分成多少块,这样子左右的面积已知,再枚举一下横着切还是竖着切,这样子就可 ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- noip2016十连测题解
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...
- BZOJ-2561-最小生成树 题解(最小割)
2561: 最小生成树(题解) Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1628 Solved: 786 传送门:http://www.lyd ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
- 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解
题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...
- 2016ACM青岛区域赛题解
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- poj1399 hoj1037 Direct Visibility 题解 (宽搜)
http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...
- 网络流n题 题解
学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...
随机推荐
- position: absolute 如果不设置left, right, top, bottom会在什么位置
一般我们设置position: absolute都会一起设置left/right/top/bottom, 但是如果不设置, 布局会是什么样子的呢? 直接上图 1.一个大盒子中4个小盒子, 正常文档流布 ...
- CSIC_716_20191213【内置函数exec、元类】
In memory of the more than 300 thousand Chinese murdered exec( 字符类型的代码,全局变量,局部变量 ).其中,全局变量和局部变量可以写成字 ...
- React 组件间传值
壹 .了解React传值的数据 一. 创建组件的方法 一 . 1 通过function声明的组件特点是: 1)function创建的组件是没有state属性,而state属性决定它是不是有生命周期 ...
- Boost Download
{ //https://www.boost.org/users/history/version_1_71_0.html }
- qt中使用sqlite存储数据
一.sqilte的安装 在Windows上安装SQLite: 请访问 SQLite 下载页面,从 Windows 区下载预编译的二进制文件. 您需要下载 sqlite-tools-win32-*.zi ...
- 区间dp+预处理——cf1278F(难题)
感觉很难的区间dp,主要是状态难想 /* 对于一个区间[i,j],设其最小的颜色编号是c=Min[i,j],那么该区间显然有一大段是以c为底的 设这个颜色在该区间出现位置的两端是L[c],R[c],那 ...
- Linux下安装PHP的mcrypt扩展
首先下载,并安装 libmcrypt-2.5.8.tar.gz 下载地址: http://sourceforge.net/project/showfiles.php?group_id=87941&am ...
- Spring源码剖析3:Spring IOC容器的加载过程
本文转自五月的仓颉 https://www.cnblogs.com/xrq730 本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 https ...
- Dubbo入门到精通学习笔记(八):ActiveMQ的安装与使用(单节点)、Redis的安装与使用(单节点)、FastDFS分布式文件系统的安装与使用(单节点)
文章目录 ActiveMQ的安装与使用(单节点) 安装(单节点) 使用 目录结构 edu-common-parent edu-demo-mqproducer edu-demo-mqconsumer 测 ...
- PAT_A1101#Quick Sort
Source: PAT A1101 Quick Sort (25 分) Description: There is a classical process named partition in the ...