忽然觉得这个题很有必要写题解。

移项

y-x^2 = bx+c

那么其实就是找有多少条直线上方没有点

所以就是一个上凸壳有多少条直线/点.

绝妙啊!!!!

太妙了啊!!!!

神乎其技卧槽!!!

(我是傻逼)

 #include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long db;
const double eps=1e-;
const double pi=acos(-);
int sign(db k){
if (k>eps) return ; else if (k<-eps) return -; return ;
}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{
db x,y;
point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
point operator * (db k1) const{return (point){x*k1,y*k1};}
point operator / (db k1) const{return (point){x/k1,y/k1};}
bool operator == (const point &k1) const{return cmp(x,k1.x)==&&cmp(y,k1.y)==;}
bool operator <(const point &k1)const {
int c=cmp(x,k1.x);
if(c)return c==-;
return cmp(y,k1.y)==-;
}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
db dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}
int n;
vector<point> convexHull(vector<point> ps){
int n = ps.size();if(n<=)return ps;
sort(ps.begin(),ps.end());
vector<point> qs(n*);int k=;
for(int i=;i<n;qs[k++]=ps[i++])
while (k>&&cross(qs[k-]-qs[k-],ps[i]-qs[k-])<=)--k;
for(int i=n-,t=k;i>=;qs[k++]=ps[i--])
while (k>t&&cross(qs[k-]-qs[k-],ps[i]-qs[k-])<=)--k;
qs.resize(k-);
return qs;
}
void getUDP(vector<point>A,vector<point>&U,vector<point>&D){
db l=1e7,r=-1e7;
for (int i=;i<A.size();i++) l=min(l,A[i].x),r=max(r,A[i].x);
int wherel,wherer;
for (int i=;i<A.size();i++) if (cmp(A[i].x,l)==) wherel=i;
for (int i=A.size();i;i--) if (cmp(A[i-].x,r)==) wherer=i-;
U.clear(); D.clear(); int now=wherel;
while (){D.push_back(A[now]); if (now==wherer) break; now++; if (now>=A.size()) now=;}
now=wherel;
while (){U.push_back(A[now]); if (now==wherer) break; now--; if (now<) now=A.size()-;}
}
vector<point>p,u,d;
db x,y;
int main(){
scanf("%d",&n);
db mx=;
for(int i=;i<=n;i++){
scanf("%lld%lld",&x,&y);
p.push_back(point{x,y-x*x});
mx+=x;
}
p=convexHull(p);
getUDP(p,u,d);
set<int>s;
for(auto p:u)s.insert(p.x);
printf("%d\n",s.size()-);
}

cf 1142 C的更多相关文章

  1. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  2. mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' when using LOCK TABLES

    AutoMySQLBackup备份时,出现mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@' ...

  3. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  4. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  5. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  6. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  7. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  8. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  9. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

随机推荐

  1. dialog自适应大小、固定大小、底部显示

    创建一个从底部显示的对话框 if (dialog == null) { dialog = new Dialog(context, R.style.theme_from_bottom); View vi ...

  2. AXI4 STREAM DATA FIFO

    参考:http://www.xilinx.com/support/documentation/ip_documentation/axis_infrastructure_ip_suite/v1_1/pg ...

  3. 正则表达式匹配日期,支持闰年,格式为YYYYMMDD

    年份:[\d]{4} 带31的月份:(0[13578]|1[02])((0[1-9])|([12][0-9])|(3[01])) 非2月不带31日的月份:((0[469])|11)((0[1-9])| ...

  4. idea的一些设置

    在File->Settings->Appearance & Behavior->System Settings->Updates下取消Automatically che ...

  5. JAVA Scanner的简单运用

    package Code428; import java.util.Scanner; /*Scanner 可以实现键盘输入数据 引用的步骤1.import 包路径.类名称只有java.lang包下的内 ...

  6. Google Python命名规范

    Google Python命名规范 module_name,  模块 package_name,  包 ClassName,  类 method_name,  方法 ExceptionName,    ...

  7. Linux安装Discuz

    安装lamp环境 安装参考 安装Discuz 1.进入官网 2.进入Discuz! 程序发布 3.选择最新版本 4.进入git地址 5.克隆下载 5. 确认Apache中的DocumentRoot配置 ...

  8. Blend 打开psd文件

    1.创建完项目后->文件->导入ps文件->选择psd文件

  9. Java Swing 编程 JComboBox 显示不全问题。

    最近在做Java Swing编程一个小例子.然后遇到JComboBox 宽度固定,而下拉列表比较长,导致显示不全的问题. 解决的思路想到两种,1:下拉列表当显示不全的时候,换行显示.2:在下拉列表停几 ...

  10. Emacs中的拼写检查

    无论是在Emacs中写英文日记(diary).Org mode笔记,还是撰写程序的注释和文档,拼写检查都是一项提高工作效率.保证成果品质的必不可缺的工具.拼写检查对于常见的文字处理软件(如Word.L ...