zoukankan      html  css  js  c++  java
  • P4160 [SCOI2009]生日快乐 搜索

    思路:无脑搜索

    提交:1次

    题解:

    大力搜索,枚举每个状态((x,y,l))((x)指分配到的长(可能比(y)要短),(y)指分配到的宽(可能比(x)要长),(l)指剩余切的次数)分给左边几个蛋糕,右边几个蛋糕,从而确定下刀的位置。

    #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
    ",dfs(x,y,k));
    }
    }
    signed main() {
    	Luitaryi::main();
    }
    

    2019.07.22

  • 相关阅读:
    zabbix
    Tomcat 部署Web应用
    WebLogic
    WebLogic部署集群和代理服务器
    WebLogic 中的基本概念
    GIT详解和GITHUB
    Tomcat 内存溢出对应解决方式
    apache和tomcat区别
    数据库介绍
    The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
  • 原文地址:https://www.cnblogs.com/Jackpei/p/11227769.html
Copyright © 2011-2022 走看看