bzoj1024

当我看到题时,满脑子都是骚操作,然后一个都不对(会),看了黄学长的博客后

直接搜索。。。

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#define min(a,b) (a)<(b)?(a):(b);
using namespace std;
int x,y,n;
template <class T> void read(T&x)
{
  x=0;char c=getchar();int f=0;
  while(c<'0'||c>'9'){f|=(c=='-');c=getchar();}
  while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^=48),c=getchar();
  x=f?-x:x;
}
double dfs(int k,double x,double y)
{
  if(k==1)return max(x/y,y/x);
  double ans=1e30;
  for(int i=1;i<=k/2;i++)
  {
    double tx=x*i/k,ty=y*i/k;
    ans=min(ans,max(dfs(i,tx,y),dfs(k-i,x-tx,y)));
    ans=min(ans,max(dfs(i,x,ty),dfs(k-i,x,y-ty)));
  }
  return ans;
}
int main()
{
  read(x);read(y);read(n);
  printf("%.6lf",dfs(n,x,y));
  return 0;
}
View Code

 

posted @ 2017-10-26 17:25  新手-周  阅读(157)  评论(0编辑  收藏  举报