题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=291

cross product: for 2 vectors a and b, if a^b > 0, a is in the clockwise direction of b. else if a^b < 0, a is in the anti-clockwise direction of vector b. Otherwise, a^b==0, vector a and b are with the same direction or opposite direction.这道题用cross product计算。每一个点与transmitter的中心形成一个vector,对于每一个vector,循环剩余的vector,所有vector在同一方向的可以看做被覆盖的点。代码如下:

 //============================================================================
// Name : test.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================ #include <iostream>
#include <math.h>
#include <stdio.h>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <cmath>
#include <set>
#define SCF(a) scanf("%d", &a)
#define IN(a) cin>>a
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define Infinity 999999999
#define PI 3.14159265358979323846
typedef long long Int;
using namespace std; struct point {
int x, y;
}; double dis(point a, point b)
{
return pow(a.x - b.x, ) + pow(a.y - b.y, );
} double length(point a)
{
return sqrt(pow(a.x, ) + pow(a.y, ));
} double dotProduct(point a, point b)
{
return a.x*b.x + a.y*b.y;
} double crossProduct(point a, point b)
{
return a.x*b.y - b.x*a.y;
} double cosAngle(point a, point b)
{
double an = dotProduct(a, b) / (length(a)*length(b));
return an;
} int main()
{
point radar;
double r;
int N;
point points[];
double angle[];
while (scanf("%d %d %lf", &radar.x, &radar.y, &r) != EOF)
{
if (r < )
break;
SCF(N);
int index = ;
point cp;
FOR(i, , N)
{
SCF(cp.x);
SCF(cp.y);
if (dis(radar, cp) <= pow(r, ))
{
points[index].x = cp.x - radar.x;
points[index++].y = cp.y - radar.y;
}
} int maxAns = ;
FOR(i, , index)
{
int cn = ;
FOR(j, , index)
{
if (i != j)
{
double rela = crossProduct(points[i], points[j]);
if (rela >= )
cn++;
}
}
maxAns = max(maxAns, cn);
}
printf("%d\n", maxAns);
}
return ;
}

UVA 2290 Transmitters的更多相关文章

  1. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  2. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  3. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  4. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  5. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

  6. UVA数学入门训练Round1[6]

    UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...

  7. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  8. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  9. UVA - 11584 Partitioning by Palindromes[序列DP]

    UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...

随机推荐

  1. 创建Oracle表空间

    *分为四步 */ /*第1步:创建临时表空间 */ create temporarytablespace user_temp tempfile 'D:\oracle\oradata\Oracle9i\ ...

  2. Unresolved externa Round

    [ilink32 Error] Error: Unresolved external '__stdcall Round(const double, int)' referenced from e:\工 ...

  3. 算法之Python实现 - 003 : 换钱的方法数

    [题目]给定数组arr,arr中所有的值都为正数且不重复.每个值代表一种面值的货币,每种面值的货币可以使用任意张,再给定一个整数aim代表要找的钱数,求组成aim的方法数. [代码1]递归 impor ...

  4. [INet] I/O模型:同步阻塞,同步非阻塞,异步非阻塞

    POSIX 把这同步.异步两个术语定义 如下: 同步 I/O 操作( synchronous I/O opetation) 导致请求进程阻塞, 直到 I/O 操作完成: 异步 I/O 操作( asyn ...

  5. 【译】BERT表示的可解释性分析

    目录 从词袋模型到BERT 分析BERT表示 不考虑上下文的方法 考虑语境的方法 结论 本文翻译自Are BERT Features InterBERTible? 从词袋模型到BERT ​ Mikol ...

  6. alias命令详解

    1.简介: 设置指令的别名,用户可利用alias,自定指令的别名.若仅输入alias,则可列出目前所有的别名设置. alias的效力仅及于该次登入的操作.若要每次登入是即自动设好别名,可在/etc/p ...

  7. 如何自定义Django数据库中的字段

    新建完项目之后,想要自定义字段 # 创建一个自定义的字段 class MycharField(models.Field): def __inif__(self, max_lenth, *args, * ...

  8. Lua + Redis 解决高并发

    一.业务背景 优惠券业务主要提供用户领券和消券的功能:领取优惠券的动作由用户直接发起,由于资源有限,我们必须对用户的领取动作进行一些常规约束. 约束1(优惠券维度): 券的最大数量 max: 约束2( ...

  9. GCC后端移植杂记

    为GCC后端移植新的处理器架构的确是一件非常痛苦的事情. 拿到GCC源码时,发现它的规模比预想中庞大得多,但好在体系结构十分清晰,前端后端高度解耦.解耦的关键就在于内部的RTL中间代码(表达形式类似于 ...

  10. Eclipse安装TestNG插件

    TestNG按照其文档的定义是: TestNG是一个测试框架,其灵感来自JUnit和NUnit的,但引入了一些新的功能,使其功能更强大,使用更方便. TestNG是一个开源自动化测试框架;TestNG ...