标签:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 5088 | Accepted: 2686 |
Description
Input
Output
Sample Input
25 25 3.5
7
25 28
23 27
27 27
24 23
26 23
24 29
26 29
350 200 2.0
5
350 202
350 199
350 198
348 200
352 200
995 995 10.0
4
1000 1000
999 998
990 992
1000 999
100 100 -2.5
Sample Output
3
4
4
Source
题目大意:
给你一个半圆的圆心坐标
解题思路:
PS:最近有点忘记计算几何了,所以做几个简单题目熟悉一下。
首先我们需要找到这个半圆能够覆盖的点,也就是点到圆心的距离
/**
2016 - 08 - 03 下午
Author: ITAK
Motto:
今日的我要超越昨日的我,明日的我要胜过今日的我,
以创作出更好的代码为目标,不断地超越自己。
**/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9+5;
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const double eps = 1e-7;
struct Point
{
double x, y;
}a[MAXN];
double dis(Point a, Point b)
{
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
double Cross(Point a, Point b, Point c)///向量ab X ac
{
Point ab, ac;
ab.x = b.x - a.x, ab.y = b.y - a.y;
ac.x = c.x - a.x, ac.y = c.y - a.y;
return ab.x*ac.y - ab.y*ac.x;
}
int main()
{
double r;
Point R, tmp;
while(cin>>R.x>>R.y>>r)
{
if(r < 0)
break;
int n, cnt = 0, ans = 0;
cin>>n;
for(int i=0; i<n; i++)
{
cin>>tmp.x>>tmp.y;
double d = dis(tmp, R);
if(d <= r*r)
{
a[cnt].x = tmp.x;
a[cnt++].y = tmp.y;
}
}
for(int i=0; i<cnt; i++)
{
int sum = 1;
for(int j=0; j<cnt; j++)
{
if(i == j)
continue;
if(Cross(R,a[i],a[j]) >= 0)
sum++;
}
if(ans < sum)
ans = sum;
}
///cout<<"ans = ";
printf("%d\n",ans);
}
return 0;
}
POJ 1106 Transmitters(计算几何:叉积)
标签:
原文地址:http://blog.csdn.net/qingshui23/article/details/52106335