题目链接: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. 关于Vue(旅游APP)的一些总结点

    1.保持宽高比例 .wrapper{ width:100%; height:0; padding-bottom:31.25% } 2. box-sizing属性可以为三个值之一:content-box ...

  2. 海外aws-ubuntu-16.04系统使用ansible安装tidb

    本以为按照官方文档会比较顺利,没想到还是遇到了几个坑,毕竟pingcap不能考虑到所有问题 环境: 1.ubuntu:16.04LTS 2.python:2.7 小坑:因为第一次使用ubuntu,没想 ...

  3. 如果在springboot中设置了 修改了默认页面的指向 使用thymleaf模板 而请求不到静态资源 可能是

    @Configurationpublic class DefaultView extends WebMvcConfigurerationSupport { @Override public void ...

  4. python 命令行颜色

    #coding=utf-8 import ctypes,sys STD_INPUT_HANDLE = -10 STD_OUTPUT_HANDLE = -11 STD_ERROR_HANDLE = -1 ...

  5. python入门(十六):正则

    1.正则:对一些字符串实现模糊的匹配 使用场景: 爬虫:例如,网页源码里面的url都提取出来.网页里面提取我们想要的数据 分析日志:例如,拿到所有的ip,看看哪些ip访问过我的网站 2.引入包 > ...

  6. python入门(十二):面向对象

    1.场景:玩过游戏.主人公,进入了一个场景,有10个小怪物是一样的.有攻击力,血(100格).如果小怪物有多个数值需要管理,小怪物的血量.小怪物出现在屏幕的地点. 可以使用字典来进行记录: {&quo ...

  7. 吐血Eclipse Maven Selenium TestNG的各种坑

    刚入坑不久,有些是自己知识储备不够造成的,有些...那就是坑 在eclipse里面新建maven项目,然后添加testgn依赖,不多说,这个简单. 第一个坑: 然后在src/test/java这个文件 ...

  8. dubbo 面试

    1.使用dubbo+zookeeper ,如果注册中心挂掉,是否可以继续通信?(zk集群可以达到高可用,但是如果全部挂掉呢?) 我答了不可以吧(项目没用过,自学没又这深度) 正确答案: dubbo使用 ...

  9. pandas列操作集锦

    列操作 pandas的列操作 数据准备: 增 将两张表合并到一起 pd.concat([page_001,page_002]).reset_index(drop=True) 默认从上到下合,如果想从左 ...

  10. python之集合及其方法---整理集

    集合的定义: 由不同元素组成.一组无序排列的可hash值.集合中元素必须是不可变类型 集合的定义方式: 由大括号组成: 每个元素用逗号分隔: 元素书写不是key-value形式: 集合是由不同元素组成 ...