uva 1615——Highway
来源:互联网 发布:图像处理区域填充算法 编辑:程序博客网 时间:2024/06/14 05:17
题意: 给定平面上n个点,和一个值D,要求在x轴上选出尽量少的点,使得对给定的点,都有一个点离他的欧几里德距离步超过D。
思路:区间覆盖问题。以平面上的点为圆心,以D为半径,求出来一个与x周相交的左右区间,那么只要多个圆都相交的那个区间ans就不用++;
code:
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <sstream>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const int INF=0x3fffffff;const int inf=-INF;const int N=100005;const int M=2005;const int mod=1000000007;const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))#define cpy(x,a) memcpy(x,a,sizeof(a))#define fr(i,s,n) for (int i=s;i<=n;i++)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define lowbit(x) (x&-x)#define pii pair<int,int>#define mk make_pair#define IN freopen("in.txt","r",stdin);#define OUT freopen("out.txt","w",stdout);struct node{ int x,y;}v[N];int main(){ int n,l,d;; while (~scanf("%d %d",&l,&d)) { scanf("%d",&n); int len=0; fr(i,0,n-1) { int tx,ty; scanf("%d %d",&tx,&ty); int s=tx-sqrt(d*d-ty*ty);s=max(s,0); int t=tx+sqrt(d*d-ty*ty);t=min(t,l); v[i].x=s;v[i].y=t; } int s=1,t=v[0].y; fr(i,1,n-1) if (v[i].x>t) { s++; t=v[i].y; } printf("%d\n",s); }}
0 0
- uva 1615——Highway
- UVa 1615 Highway
- Uva - 1615 - Highway
- uva 1615Highway 贪心
- uva 1615 - Highway
- UVa 1615 - Highway(贪心)
- UVA - 1615 Highway 区间覆盖
- UVa 1615:Highway(贪心)
- UVA - 1615 Highway 区间覆盖
- UVa #1615 Highway (习题8-11)
- uva 1615 Highway 高速公路 (贪心算法)
- uva 1393 Highway
- UVA 1615 Highway 区间选点 经典贪心 (SEERC 2005)
- 习题8-11 UVA - 1615 Highway 高速公路 (区间枚举)
- Highway
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛:H—Highway
- UVa - 1615 Highway 高速公路 贪心+区间选点 重庆一中高2018级竞赛班第五次测试 2016.7.26 Problem 1
- pku1648Countryside Highway
- 马拉松抽筋原因及其防治
- SSH面试集锦——不看后悔哦!
- SpringMVC 基础笔记
- K-近邻分类算法KNN
- linux语句
- uva 1615——Highway
- XML--做rss订阅
- 【转】ubuntu下pppoe后网络图标(无线网络)消失的解决办法
- CodeForces 567E President and Roads(最短路 + 双联通分量)
- CSS学习笔记之<!important>
- hdu--4435--charge-station+贪心
- jquery ajax 不能正常调用success的问题
- HDOJ 5124 lines 【线段树 & 离散化】
- Ubuntu14.04 LTS更新源