P4160 [SCOI2009] Happy Birthday Search

Ideas: no brains search

Submission: 1

answer:

Vigorously search, enumerate each state \ ((the X-, the y-, L) \) ( \ (the X-\) refers to the length assigned to the (likely than \ (y \) is shorter), \ (y \) refers to the allocation width (ratio may \ (X \) is longer), \ (L \) refers to the number of remaining cut) distributed to several cake left and right several cake, to determine the location of the knife.

#include<cstdio>
#include<iostream>
#define ull unsigned long long
#define ll long long
#define R register int
using namespace std;
#define pause (for(R i=1;i<=10000000000;++i))
#define In freopen("NOIPAK++.in","r",stdin)
#define Out freopen("out.out","w",stdout)
namespace Fread {
static char B[1<<15],*S=B,*D=B;
#ifndef JACK
#define getchar() (S==D&&(D=(S=B)+fread(B,1,1<<15,stdin),S==D)?EOF:*S++)
#endif
inline int g() {
    R ret=0,fix=1; register char ch; while(!isdigit(ch=getchar())) fix=ch=='-'?-1:fix;
    if(ch==EOF) return EOF; do ret=ret*10+(ch^48); while(isdigit(ch=getchar())); return ret*fix;
} inline bool isempty(const char& ch) {return (ch<=36||ch>=127);}
inline void gs(char* s) {
    register char ch; while(isempty(ch=getchar()));
    do *s++=ch; while(!isempty(ch=getchar()));
}
} using Fread::g; using Fread::gs;

namespace Luitaryi {
#define db double
int x,y,k;
inline db dfs(db x,db y,int l) {
    if(l==1) return max(y/x,x/y); register db ret=1E+9;
    for(R i=1;i<l;++i) { register db tmp,tmp2;
        tmp=max(dfs(x*i/l,y,i),dfs(x*(l-i)/l,y,l-i));
        tmp2=max(dfs(x,y*i/l,i),dfs(x,y*(l-i)/l,l-i));
        ret=min(ret,min(tmp,tmp2));
    } return ret;
}
inline void main() {
    x=g(),y=g(),k=g(); 
    printf("%.6lf\n",dfs(x,y,k));
}
}
signed main() {
    Luitaryi::main();
}

2019.07.22

Guess you like

Origin www.cnblogs.com/Jackpei/p/11227769.html