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

移项

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. input子系统学习笔记六 按键驱动实例分析下【转】

    转自:http://blog.chinaunix.net/uid-20776117-id-3212095.html 本文接着input子系统学习笔记五 按键驱动实例分析上接续分析这个按键驱动实例! i ...

  2. 网络流板子/费用流板子 2018南京I题+2016青岛G题

    2018南京I题: dinic,链式前向星,数组队列,当前弧优化,不memset全部数组,抛弃满流点,bfs只找一条增广路,每次多路增广 #include <bits/stdc++.h> ...

  3. nginx+uwsgi+django开发环境搭建

    Nginx+uWSGI+Djangoi开发环境搭建 Django简介,环境搭建 uWSGI简介,安装与配置 Nginx安装与配置 Nginx+uWSGI+Django原理解析 1.django简介,环 ...

  4. 24 类:组合 继承 super关键字 面向对象的三大性

    组合 组合:自定义类的对象作为另外一个类的属性 class Teacher: def __init__(self, name, age): self.name = name self.age = ag ...

  5. I - Beautiful People ZOJ - 2319 (二分法)

    The most prestigious sports club in one city has exactly N members. Each of its members is strong an ...

  6. layUI实现可选项 弹框

    需求描述:点击插入,会让选择,插入的类型,选择之后,点击确定,执行后续的一些操作.先摆效果图. 代码: //html代码<style> #imp{ display: none; }< ...

  7. 《剑指offer》左旋转字符串

    本题来自<剑指offer> 反转链表 题目: 思路: C++ Code: Python Code: 总结:

  8. Jace 上新建 Station 配置 笔记

    1.Station站点的结构图 2.niagara 结构框架图 Niagara 系统的架构是围绕着“以组件(Component)为导向的编程”为核心设计的.组件(Component)是使用Java 编 ...

  9. webstorm 2019.1 注册教程

    注册教程:https://blog.csdn.net/hdp134793/article/details/81530472 IntelliJ IDEA 注册码获取网站

  10. Python3——坦克大战

    # coding=utf-8 # Version:python3.6.1 __date__ = '2018/9/20 18:51' __author__ = 'Lgsp_Harold' import ...