#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll ;
typedef double db ;
const db eps = 1e-4 ;
const int N = 1e5 + 1 ;
double L , D ;
int n ;
int check ( db x , db y ) {
if ( fabs ( x - y ) < eps )return 0 ;
return 1 ;
}
struct node {
db l , r ;
node ( db x = 0 , db y = 0 ) : l ( x ) , r ( y ) {}
bool operator < ( const node & rhs ) {
if ( check ( r , rhs . r ) == 0 ) return l < rhs . l ;
return r < rhs . r ;
}
void read ( db x , db y , db d ) {
double sq = sqrt ( d * d - y * y ) ;
l = x - sq ;r = x + sq ;
l = l < 0.000 ? 0.000 : l ;
r = r > L ? L : r ;
return ;
}
} point [ N ] ;
int main ( ) {
/*
freopen ( "text.in" , "r" , stdin ) ;
freopen ( "text.out" , "w" , stdout ) ;
*/
WORK:
if ( scanf ( "%lf%lf%d" , & L , & D , & n ) == EOF ) return 0 ;
for ( int i = 0 ; i < n ; i ++ ){
static double x , y ;
scanf ( "%lf%lf" , & x , & y ) ;
point [ i ] . read ( x , y , D ) ;
}
sort ( point , point + n ) ;
int ans = 1 ; db now = point [ 0 ] . r ;
for ( int i = 1 ; i < n ; i ++ ) {
if ( point [ i ] . l > point [ i ] . r ) continue;
if ( check ( point [ i ] . l , point [ i - 1 ] . l ) == 0 || check ( point [ i ] . l , now ) == 0 )
continue;
if ( point [ i ] . l > now ) now = point [ i ] . r , ans ++ ;
}
printf ( "%d\n" , ans ) ;
goto WORK;
return 0 ;
}
标签:UVA1615,return,point,int,db,高速公路,include,check,Highway
From: https://www.cnblogs.com/dadidididi/p/16982957.html