BZOJ1024&丝帛搜索

题意:

  还想二分的,发现并不用...那么直接搜索就水过吧...

/*=================================================================
# Created time: 2016-03-28 21:10
# Filename: 1024.cpp
# Description: 
=================================================================*/
#define me AcrossTheSky 
#include <cstdio> 
#include <cmath> 
#include <ctime> 
#include <string> 
#include <cstring> 
#include <cstdlib> 
#include <iostream> 
#include <algorithm> 
  
#include <set> 
#include <map> 
#include <stack> 
#include <queue> 
#include <vector> 
 
#define lowbit(x) (x)&(-x) 
#define FOR(i,a,b) for((i)=(a);(i)<=(b);(i)++) 
#define FORP(i,a,b) for(int i=(a);i<=(b);i++) 
#define FORM(i,a,b) for(int i=(a);i>=(b);i--) 
#define ls(a,b) (((a)+(b)) << 1) 
#define rs(a,b) (((a)+(b)) >> 1) 
#define getlc(a) ch[(a)][0] 
#define getrc(a) ch[(a)][1] 
 
#define maxn 500
#define maxm 100000 
#define pi 3.1415926535898 
#define _e 2.718281828459 
#define INF 1070000000 
using namespace std; 
typedef long long ll; 
typedef unsigned long long ull; 
 
template<class T> inline 
void read(T& num) { 
    bool start=false,neg=false; 
    char c; 
    num=0; 
    while((c=getchar())!=EOF) { 
        if(c=='-') start=neg=true; 
        else if(c>='0' && c<='9') { 
            start=true; 
            num=num*10+c-'0'; 
        } else if(start) break; 
    } 
    if(neg) num=-num; 
} 
/*==================split line==================*/ 
int x,y,n;
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;
}

 

posted @ 2016-03-28 22:08  YCuangWhen  阅读(138)  评论(0编辑  收藏  举报