zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    【python刷题】前缀和
    【python刷题】数组链表去重
    【python刷题】滑动窗口法
    【python刷题】二分查找
    【python刷题】广度优先搜索(BFS)
    【python刷题】回溯算法(深度优先搜索DFS)
    机器学习十讲-第三讲分类
    数学知识-质数&约数
    树与图的DFS与BFS
    桥梁保护与监控-开发进度(二)
  • 原文地址:https://www.cnblogs.com/YCuangWhen/p/5330890.html
Copyright © 2011-2022 走看看