# 【BZOJ 1024】 [SCOI2009]生日快乐

【题目链接】:http://www.lydsy.com/JudgeOnline/problem.php?id=1024

【题意】

【题解】

【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x)

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 110;

int x, y, n;

void input_data()
{
rei(x), rei(y), rei(n);
}

double dfs(double x, double y, int z)
{
if (z == 1)
{
if (x < y) swap(x, y);
return x / y;
}
double tt = z;
double xx = x / tt;
double z1 = 21e8;
rep1(i, 1, z-1)
{
double t = xx*i;
double temp1 = dfs(t, y, i);
temp1 =max(temp1, dfs(x - t, y, z - i));
z1 = min(z1, temp1);
}

double yy = y / tt;
rep1(i, 1, z-1)
{
double t = yy*i;
double temp1 = dfs(x, t, i);
temp1 = max(temp1, dfs(x, y - t, z - i));
z1 = min(z1, temp1);
}
return z1;
}

int main()
{
//freopen("F:\\rush.txt", "r", stdin);
input_data();
printf("%.6f\n", dfs(x, y, n));
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}

posted @ 2017-10-04 18:45  AWCXV  阅读(61)  评论(0编辑  收藏