题目链接: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. 记录小白实习生的HashMap源码 put元素 的学习和一些疑问

    首先看HashMap存储结构 transient Node<K,V>[] table; static class Node<K,V> implements Map.Entry& ...

  2. K8s简单yaml文件运行例子deployment

    kubectl run 创建并运行一个或多个容器镜像. 创建一个deployment 或job 来管理容器. kubectl run 语法: $ run NAME --image=image [--e ...

  3. winfrom中pictureBox控件的部分使用方法

    一.后台属性 1.pictureBox1.Image显示图片 2.pictureBox1.ImageLocation存储和提取图片路径 二.面板属性 1.Picturebox控件SizeMode属性 ...

  4. Failed to introspect annotated methods on class 异常

    用@enable时出现错误 Failed to introspect annotated methods on class 很可能是库和springboot版本不一致

  5. Jenkins Maven Selenium TestNG踩坑记

    1)Maven TestNG什么的都配置好了,在本地用eclipse->Run AS->MAVEN INSTALL运行正常 2) Jenkins安装了插件,也建立了MAVEN项目.MAVE ...

  6. Java框架spring 学习笔记(十三):log4j介绍

    功能 日志功能,通过log4j可以看到程序运行过程的详细信息. 使用 导入log4j的jar包 复制log4j的配置文件,复制到src下面   3.设置日志级别 info:看到基本信息 debug:看 ...

  7. spring mvc 参数绑定

    基础类型 原始类型:id必须要传,否则报错. @RequestMapping("/test") @ResponseBody public ResponseData test(int ...

  8. 企业BGP网络规划案例(一)

    网络拓扑: 如上图为一家企业的办公网,分为总部AS6500,分公司AS65001和分公司AS65002,其中每个站点都有生产.办公和服务器区域的网络互访,分公司和总公司之间通过两条联通/电信的MSTP ...

  9. vue props命名最好直接使用kebab-case (短横线隔开式) 命名

    vue官方解释,props使用驼峰命名的话,在html中使用时也需要转化成短横线命名,否则报错.个人比较喜欢上下文统一,直接在props命名时就把它命名成短横线隔开式吧.

  10. python基础(17)继承类和面向对象初识

    1.继承类 class Lm: money = 1000000 house = 5 def driver(self): print('会开车') class Mcb(Lm): def about_me ...