大致题意:

    有一个人想要获得p个经验点和q元钱。现在给出n份工作,每份工作每天能得到Ai的经验值和Bi的钱,问最少需要工作多少天,

    能使得总经验值>=p,总钱>=q。

  

    先对给出的n份工作以及原点O(0,0),x轴的最大点(maxx,0),y轴最大点(0,maxy)构建凸包,根据凸组合,可知凸包上所有得点以

    及凸包边上的点都可以由一天时间得到,那么只要求出射线O~P(p,q)与凸包的交点,即可求出最后的结果。

    

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 200100
#define eps 1e-5
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fre freopen
#define pi acos(-1.0)
#define inf 1e9+9
#define Vector Point
const int Mod=1e9+;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dcmp(double x){
if(fabs(x)<=eps) return ;
return x<?-:;
}
struct Point {
double x,y;
int id;
int pre,nxt;
Point(double x=,double y=) : x(x),y(y) {}
Point operator - (const Point &a)const{ return Point(x-a.x,y-a.y); }
Point operator + (const Point &a)const{ return Point(x+a.x,y+a.y); }
Point operator * (const double &a)const{ return Point(x*a,y*a); }
Point operator / (const double &a)const{ return Point(x/a,y/a); }
bool operator < (const Point &a)const{ if(x==a.x) return y<a.y;return x<a.x; }
bool operator == (const Point &a)const{ return dcmp(x-a.x)== && dcmp(y-a.y)==; }
void read(int iid=) { scanf("%lf%lf",&x,&y);id=iid; }
void out(){cout<<"Bug: "<<x<<" "<<y<<endl;}
};
inline double Cross(Vector a,Vector b) { return a.x*b.y-a.y*b.x; }
inline double Dot(Vector a,Vector b) { return a.x*b.x+a.y*b.y; }
inline double dis(Vector a) { return sqrt(Dot(a,a)); }
int ConvexHull(Point *p,int n,Point *ch){
int m=;
sort(p,p+n);
For(i,,n-){
p[i].id=i;
while(m> && Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=) m--;
ch[m++]=p[i];
}
int k=m;
Fore(i,n-,){
while(m>k && Cross(ch[m-]-ch[m-],p[i]-ch[m-])<=) m--;
ch[m++]=p[i];
}
if(n>) m--;
return m;
}
inline bool Onsegment(Point a,Point b1,Point b2){
return dcmp(Cross(b1-a,b2-a))== && dcmp(Dot(b1-a,b2-a))<;
}
bool Intersect_Segm_Ray(Point a1,Vector u,Point b1,Point b2){
double c1=Cross(b1-a1,u),c2=Cross(b2-a1,u);
if(dcmp(c2)*dcmp(c1)>) return ;
if(dcmp(c2)*dcmp(c1)<){
c1=Dot(b1-a1,u);c2=Dot(b2-a1,u);
return dcmp(c1)>= && dcmp(c2)>=;
}
if(c1==) return dcmp(Dot(b1-a1,u))>;
if(c2==) return dcmp(Dot(b2-a1,u))>;
}
Point Intersect_Line_Point(Point p,Vector u,Point q,Vector v){
Vector w=p-q;
double t=Cross(v,w)/Cross(u,v);
return p+u*t;
}
int n;
double maxx,maxy;
Point p[MAXN],cp;
Point ch[MAXN];
int solve(){
double ans=inf;maxx=;maxy=;
cin>>n;cp.read();
For(i,,n-) p[i].read(),maxx=max(p[i].x,maxx),maxy=max(p[i].y,maxy);
p[n]=Point(,);
p[n+]=Point(,maxy);
p[n+]=Point(maxx,);
int m=ConvexHull(p,n+,ch);
For(i,,m-){
if(ch[i]==Point(,) || ch[(i+)%m]==Point(,)) continue;
if(Intersect_Segm_Ray(Point(,),cp,ch[(i+)%m],ch[i])){
Point st=Intersect_Line_Point(cp,cp,ch[i],ch[(i+)%m]-ch[i]);
ans=min(ans,dis(cp)/dis(st));
}
}
printf("%.15lf\n",ans);
}
int main(){
// fre("in.txt","r",stdin);
int t=;
while(t--)solve();
return ;
}

     

[CodeForces-606E] Freelancer's Dreams 凸包 模型转换的更多相关文章

  1. Codeforces 605C Freelancer's Dreams 凸包 (看题解)

    Freelancer's Dreams 我们把每个二元组看成是平面上的一个点, 那么两个点的线性组合是两点之间的连线, 即x * (a1, b1) + y * (a1, b1) && ...

  2. Codeforces Round #335 (Div. 1) C. Freelancer's Dreams 计算几何

    C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ...

  3. CF#335 Freelancer's Dreams

    Freelancer's Dreams time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. 前端MVVM框架avalon - 模型转换1

    轻量级前端MVVM框架avalon - 模型转换(一) 接上一章 ViewModel modelFactory工厂是如何加工用户定义的VM? 附源码 洋洋洒洒100多行内部是魔幻般的实现 1: fun ...

  5. 将List 中的ConvertAll的使用:List 中的元素转换,List模型转换, list模型转数组

    一,直接入代码 using System; using System.Collections.Generic; using System.Linq; using System.Web; using S ...

  6. Verification of Model Transformations A Survey of the State-of-the-Art 模型转换的验证 对现状的调查

    模型驱动工程范式认为软件开发生命周期由工件(需求规范.分析和设计文档.测试套件.源代码)支持,这些工件是表示要构建的系统不同视图的模型.存在一个由模型转换驱动的(半)自动构造过程,从系统的抽象模型开始 ...

  7. 【tensorflow-v2.0】如何将模型转换成tflite模型

    前言 TensorFlow Lite 提供了转换 TensorFlow 模型,并在移动端(mobile).嵌入式(embeded)和物联网(IoT)设备上运行 TensorFlow 模型所需的所有工具 ...

  8. 洛谷P1155 双栈排序题解(图论模型转换+二分图染色+栈)

    洛谷P1155 双栈排序题解(图论模型转换+二分图染色+栈) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/1311990 原题地址:洛谷P1155 双栈排序 ...

  9. 【机器学习】使用CNN神经网络实现对图片分类识别及模型转换

    仅做记录,后面慢慢整理 训练函数: from skimage import io, transform # skimage模块下的io transform(图像的形变与缩放)模块 import glo ...

随机推荐

  1. Ubuntu安装Nginx 问题以及解决办法

    Error1 the HTTP rewrite module requires the PCRE library sudo apt-get update sudo apt-get install li ...

  2. RHEL-7.0重置root密码

    RHCE考试第一个环节就是重置root密码,然而7系列与6系列又存在着很大的不同.以下为RHEL-7.0系统对root密码重置的步骤! 1.开机出现引导菜单时按下e键    2.找到linux16行, ...

  3. nodejs压缩

    在express中要用到压缩,把某一个文件夹压缩成zip,再返回到客户端提供下载. 用archiver库 var Archiver = require('archiver') router.get(' ...

  4. 你应该了解的强大CSS表达式 ----- expression

    IE5及其以后版本支持在CSS中使用expression,用来把CSS属性和Javas cript表达式关联起来,这里的CSS属性可以是元素固有的属性,也可以是自定义属性.就是说CSS属性后面可以是一 ...

  5. 20145202马超 2016-2017-2 《Java程序设计》第5周学习总结

    20145202马超 2016-2017-2 <Java程序设计>第5周学习总结 教材学习内容总结 异常:程序在运行的时候出现不正正常的情况 由来:问题也是可以通过java对不正常情况进行 ...

  6. eclipse配置hadoop插件

    1. 版本信息   eclipse windows 64 bit hadoop 2.5.2 64 bit hadoop eclipse-plug 2.5.2   2. 下载hadoop-2.5.2.t ...

  7. datagrid时间插件

    jquery easyui日期控件中,在页面里用JS拿到设立的日期值的方法 链接:http://blog.csdn.net/liweibin_/article/details/13509917 jqu ...

  8. shell操作典型案例--FTP操作

    从FTP服务器上下载文件或上传文件到FTP服务器是生产环境中比较常见的场景之一. shell操作FTP的方式整理如下: 思路一:使用shell调用ftp等客户端 使用FTP方式,通过shell调用ft ...

  9. python调用百度语音识别接口实时识别

    1.本文直接上干货 奉献代码:https://github.com/wuzaipei/audio_discern/tree/master/%E8%AF%AD%E9%9F%B3%E8%AF%86%E5% ...

  10. rsync同步文件(多台机器同步代码...)

    常用组合   rsync -av --delete-after --exclude-from="a.txt"  x/x -e ssh x:/x/x   a.txt 制定忽略的文件, ...