大致题意:

    有一个人想要获得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. Bittersweet——NOIP2018 游记

    p { font-size: 16px; line-height: 1.5em; } blockquote { font-family: 'Times New Roman', 楷体; text-ali ...

  2. sublime text3 最常用的快捷键及插件

    A:最常用的快捷键 Tab:自动补齐代码 <!--div+Tab 其它标签一样--><div></div> emmet常用的使用方法 <!--ul>li ...

  3. 双11怎么那么强!之二:浅析淘宝网络通信库tbnet的实现

    最近开始看Tair的源码实现,Tair的通信使用的是淘宝的开源的网络库tbnet实现.具体来说是依靠tbnet::Transport类型实现,其源代码路径如下:http://code.taobao.o ...

  4. 【COGS】2287:[HZOI 2015]疯狂的机器人 FFT+卡特兰数+排列组合

    [题意][COGS 2287][HZOI 2015]疯狂的机器人 [算法]FFT+卡特兰数+排列组合 [题解]先考虑一维的情况,支持+1和-1,前缀和不能为负数,就是卡特兰数的形式. 设C(n)表示第 ...

  5. 【蓝桥杯单片机11】单总线温度传感器DS18B20的基本操作

    [蓝桥杯单片机11]单总线温度传感器DS18B20的基本操作 广东职业技术学院 欧浩源 单总线数字温度传感器DS18B20几乎成了各类单片机甚至ARM实验板的标配模块来,在蓝桥杯的往届省赛和国赛中,这 ...

  6. Python练习-函数版-锁定三次登陆失败的用户

    代码如下: # 编辑者:闫龙 if __name__ == '__main__': import UserLoginFuncation LoclCount=[]; while True: UserNa ...

  7. 2016.5.21——Compare Version Numbers

    Compare Version Numbers 本题收获: 1.字符串型数字转化为整型数字的方法:s[i] - '0',( 将字母转化为数字是[i]-'A'   ) 2.srt.at(),substr ...

  8. margin-bottom无效问题以及div里内容动态居中样式!

    最近调前端样式时候,遇到一个需求,在中间文字不对等的情况下想让下面的操作文字距离底部对齐,如图: , 刚开始觉得使用margin-bottom就可以,后来发现只有margin-top是管用的,查了资料 ...

  9. 【算法学习】manacher

    manacher太水了. 这篇blog不能称作算法学习,因为根本没有介绍…… 就贴个模板,太简单了…… #include<cstdio> #include<cstring> # ...

  10. JDK1.8源码LinkedList

    引用博文链接 : https://www.cnblogs.com/leskang/p/6029780.html LinkedList继承了 AbstractSequentialList抽象类,而不是像 ...