UVA 2290 Transmitters
题目链接: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的更多相关文章
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
- UVA计数方法练习[3]
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...
- 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 ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
- UVA - 10375 Choose and divide[唯一分解定理]
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- 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 ...
随机推荐
- python爬虫相关
一.Python re模块的基本用法: https://blog.csdn.net/chenmozhe22/article/details/80601971 二.爬取网页图片 https://www. ...
- 一文读懂PRBS定义、生成办法、作用
对于眼图测试.误码率和抖动容限测试,最常用的测试码是PRBS,主要有PRBS7.PRBS15.PRBS23和PRBS31.本文主要解释了PRBS的定义,生成方法以及简单应用. PRBS定义 二进制序列 ...
- Tesseract-OCR的使用记录
参考: http://www.cnblogs.com/cnlian/p/5765871.html http://www.cnblogs.com/wzben/p/5930538.html 1.下载 Te ...
- python3下调用系统massagebox对话框
#python3下调用系统massagebox对话框#先安装pwin32插件https://github.com/mhammond/pywin32/releases import win32apiim ...
- FPGA——入手(零)
前几天正点原子团队退出了FPGA开发板,我就买了一套.我想的是,多学一点东西,即使到最后积累下的东西少,但是面是广的,以后可以更好的选择一种深入.就入手了新起点FPGA开发板,新起点算是开拓者的阉割版 ...
- tensorflow 如何读取npy文件里的参数
import numpy as npc = np.load( "vgg16.npy" ) #npy的文件名x = c.item() #此时,x的type是一个字典nam ...
- cobbler登录web界面时出现“Internal Server Error”
当进行cobbler配置后,并进行web登录时,出现错误: 先查看其日志位置 #cat /etc/httpd/conf.d/ssl.conf 在其中位置发现其错误的日志位置为/etc/httpd/lo ...
- 阿里云从0安装mysql到远程连接
1.安装mysql数据库. (1)下载mysql源安装包:wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rp ...
- ensureCapacity增加此 ArrayList 实例的容量,以确保它至少能够容纳最小容量参数所指定的元素数。
扩容原则: 若参数值大于底层数组长度的1.5倍,则数组的长度就扩容为这个参数值:若小于底层数组长度的1.5倍,则数组长度就扩容为底层数组长度的1.5倍. ensureCapacity提高效率 fina ...
- [phvia/dkc] Docker Compose 快速构建(LNMP+Node)运行环境
快速构建(LNMP+Node)运行环境. dkc 在此作为 docker-compose 的缩写,你可以理解为 alias dkc=docker-compose 准备 安装 docker 选择1) 从 ...