zoukankan      html  css  js  c++  java
  • codeforce 605BE. Freelancer's Dreams

    题意:给你n个工程,做了每个工程相应增长x经验和y钱。问你最少需要多少天到达制定目标。时间可以是浮点数。

    思路:杜教思路,用对偶原理很简易。个人建议还是标准解题法,凸包+线性组合。

     1 #include<iostream>
     2 #include<string>
     3 #include<algorithm>
     4 #include<cstdlib>
     5 #include<cstdio>
     6 #include<set>
     7 #include<map>
     8 #include<vector>
     9 #include<cstring>
    10 #include<stack>
    11 #include<cmath>
    12 #include<queue>
    13 #include <bits/stdc++.h>
    14 using namespace std;
    15 #define CL(x,v); memset(x,v,sizeof(x));
    16 #define INF 0x3f3f3f3f
    17 #define LL long long
    18 const int SIGMA_SIZE = 26;
    19 const int MAXNODE = 111000;
    20 const int MAXS = 150 + 10;
    21 const int maxn = 1e5+10;
    22 int a[maxn], b[maxn];
    23 int n, p, q;
    24 
    25 double f(double x)
    26 {
    27     double y = 1;
    28     for(int i=0;i<n;i++) y = min(y, (1.0 - x*b[i]) / a[i]);
    29     return y*p + x*q;
    30 }
    31 
    32 int main()
    33 {
    34     cin >> n >> p >> q;
    35     for(int i=0;i<n;i++) cin >> a[i] >> b[i];
    36     double l=0, r = 1./ (*max_element(b, b+n));
    37     for(int i=0;i<200;i++)
    38     {
    39         double ll = (l+l+r)/3, rr = (r + r+l)/3;
    40         if(f(ll) > f(rr)) r = rr;
    41         else l = ll;
    42     }
    43     printf("%.10f
    ", f((l+r)*0.5));
    44     return 0;
    45 }
    View Code
  • 相关阅读:
    HTML5 文件上传
    Vue-Router模式、钩子
    网络基础协议随笔
    Vue-Router基础使用
    vue中mixin的一点理解
    纯css3跑马灯demo
    Charles使用笔记
    提个醒。。。
    本机未装Oracle数据库时Navicat for Oracle 报错:Cannot create oci environment 原因分析及解决方案
    easyUI datagrid 清空
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5049951.html
Copyright © 2011-2022 走看看