Nearby Bicycles
With fast developments of information and communication technology, many cities today have established bicycle sharing systems. The key component of the system is to provide information on nearby bicycles to potential users.
Consider mmm bicycles and nnn customers, where each bicycle is located at coordinate (cj,dj)(c_j , d_j )(cj,dj) for j=1,2,...,m,j = 1, 2, ... , m,j=1,2,...,m, and each user iii is located at coordinate (ai,bi)(a_i, b_i)(ai,bi) for i=1,2,...,ni = 1, 2, ... , ni=1,2,...,n The distance between two coordinates (x,y)(x, y)(x,y) and (x,y)(x, y)(x,y) is measured by (x−x)2+(y−y)2 \sqrt{(x-x)^2 +(y-y)^2}(x−x)2+(y−y)2 . For each user i=1,2,...,ni = 1,2,...,ni=1,2,...,n, you are given a threshold sis_isi, your task is to return the total number of bicycles that are within a distance of si from user iii.
Input
The test data may contain many test cases. Each test case contains four lines. The first line of each case contains two integers, mmm and n(0<m,n≤1000)n (0 < m, n \le 1000)n(0<m,n≤1000). The second line contains the coordinates, (c1,d1),(c2,d2),...,(cm,dm)(c_1, d_1), (c_2, d_2), ... , (c_m, d_m)(c1,d1),(c2,d2),...,(cm,dm), of bicycles 1,2,...,m 1, 2, ... , m1,2,...,m, respectively, which are separated by a space. The third line contains the coordinates,(a1,b1),(a2,b2),...,(an,bn)(a1, b1), (a2, b2), ... , (an, bn)(a1,b1),(a2,b2),...,(an,bn), of users 1,2,...,n1, 2,... , n1,2,...,n, respectively, which are separated by a space. contains the thresholds, s1,s2,...,sns_1, s_2, ... , s_ns1,s2,...,sn, of the nnn users. The last test case is followed by a line of two 000s. All the number of coordinate in the input is in the range [−100000,100000][-100000, 100000][−100000,100000].
Output
The output for each test case contains a line of nnn integers, k1,k2,...,knk_1, k_2, ... , k_nk1,k2,...,kn, where each ki represents the total number of bicycles that are within a distance of sis_i si from user iii, for i=1,2,...,ni = 1,2,...,ni=1,2,...,n.
样例输入
4 2
(0,0) (0,1) (1,0) (1,1)
(0,0) (1,1)
1 1
0 0
样例输出
3 3 C++期末考试题。。。
基本输入输出,傻了。
那个括号完全可以当作字符输入然后不管他的嘤嘤嘤。
强行用gets带偏队友
然后又强行用字符串带偏队友
每说一句话要深思熟虑,否则就成为坑货了。。。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct data
{
ll x=,y=;
ll dist=;
ll ans=;
};
ll fun(ll x1,ll x2,ll y1,ll y2)
{
return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
char s[]= {};
int main()
{
ios::sync_with_stdio(false);
int n,m;
char e,f,g;
while(cin>>n>>m&&n&&m){
int i;
data a[];
data b[];
for(i=; i<=n; i++) cin>>e>>a[i].x>>f>>a[i].y>>g;
for(i=; i<=m; i++) cin>>e>>b[i].x>>f>>b[i].y>>g;
for(i=; i<=m; i++)
{
ll si;
cin>>si;
b[i].dist=si*si;
}
int j;
for(i=; i<=m; i++)
{
for(j=; j<=n; j++)
{
ll dd=fun(a[j].x,b[i].x,a[j].y,b[i].y);
if(dd<=b[i].dist) b[i].ans++;
}
}
for(i=; i<m; i++) cout<<b[i].ans<<" ";
cout<<b[i].ans<<endl;
}
return ;
}
Nearby Bicycles的更多相关文章
- ACM-ICPC 2017 Asia HongKong 解题报告
ACM-ICPC 2017 Asia HongKong 解题报告 任意门:https://nanti.jisuanke.com/?kw=ACM-ICPC%202017%20Asia%20HongKon ...
- 【洛谷3047】[USACO12FEB]附近的牛Nearby Cows
题面 题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into acc ...
- 【bzoj2591】[Usaco 2012 Feb]Nearby Cows 树形dp
题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into accoun ...
- 树形DP【洛谷P3047】 [USACO12FEB]附近的牛Nearby Cows
P3047 [USACO12FEB]附近的牛Nearby Cows 农民约翰已经注意到他的奶牛经常在附近的田野之间移动.考虑到这一点,他想在每一块土地上种上足够的草,不仅是为了最初在这片土地上的奶牛, ...
- [USACO12FEB]附近的牛Nearby Cows
题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into accoun ...
- 洛谷P3047 [USACO12FEB]Nearby Cows(树形dp)
P3047 [USACO12FEB]附近的牛Nearby Cows 题目描述 Farmer John has noticed that his cows often move between near ...
- 洛谷 P3047 [USACO12FEB]附近的牛Nearby Cows
P3047 [USACO12FEB]附近的牛Nearby Cows 题目描述 Farmer John has noticed that his cows often move between near ...
- 如何用HMS Nearby Service给自己的APP开发一个名片交换功能?
在工作和生活中,遇见新的同事或者合作伙伴,交换名片是一个常见的用户需求,纸质名片常忘带.易丢失,是客户的一个痛点.因此,市场上出现了很多交换电子名片的APP和小程序.那么,如何给自己的APP开发一 ...
- 如何用Nearby Service开发针对附近人群的精准广告推送功能
当你想找一家餐厅吃饭,却不知道去哪家,这时候手机跳出一条通知,为你自动推送附近优质餐厅的信息,你会点击查看吗?当你还在店内纠结于是否买下一双球鞋时,手机应用给了你发放了老顾客5折优惠券,这样的广告 ...
随机推荐
- 19 01 13 JQery 加载 选择器 样式操作
在Javascript 中应该用下方法经行编辑 <script type="text/javascript" src="js/jquery-1.12.4.min ...
- 18 11 27 高级的服务器连接 epoll
---恢复内容开始--- 之前的 http 服务器 都是采用 轮询的方式(就像 厨师挨个问谁饿了好做饭 一样 ) 而 epoll 用着高级的 方式 事件通知 (直接问谁饿了) 同时还和 计 ...
- linux-文件系统和目录
linux目录说明 /:系统根目录 /usr:用户的程序 /home:默认创建用户在此目录下创建用户主目录 /etc:存放系统配置文件.服务脚本,一些程序配置文件 /bin:常用命令 /sbin:常用 ...
- Codeforces Round #619 (Div. 2)E思维+二维RMQ
题:https://codeforces.com/contest/1301/problem/E 题意:给个n*m的图形,q个询问,每次询问问询问区间最大的合法logo的面积是多少 分析:由于logo是 ...
- tensorflow笔记(北大网课实战)
1. tf.multiply(x,y1) # 对应元素相乘 tf.matmul(x,y2) # 矩阵相乘 2.会话:执行计算图中的节点运算的. with tf.Session() as sess: p ...
- 00java语法基础和课后实践
一:运行代码,并分析结果 代码1: package reserve; public class Main { public static void main(String[] args) { Size ...
- Linux(CENTOS7) Tomcat服务成功发布但局域网浏览器无法访问
问题 : 我在linux搭建了一个tomcat服务器,tomcat开启后,发现在局域网浏览器上无法访问该tomcat,浏览器报无法访问服务器错误,我查看了tomcat的日志,路径..../tomcat ...
- MQTT--Paho C Client 的实现和详解
概述 在文章Paho - MQTT C Cient的实现中,我介绍了如何使用Paho开源项目创建MQTTClient_pulish客户端.但只是简单的介绍了使用方法,而且客户端的结果与之前介绍的并不 ...
- 更改php.ini配置
vi /etc/php.ini #编辑修改 @ini_set('memory_limit', '64M'); / ...
- 剑指offer【08】- 二叉树的深度(java)
题目:二叉树的深度 考点:知识迁移能力 题目描述:输入一棵二叉树,求该树的深度.从根结点到叶结点依次经过的结点(含根.叶结点)形成树的一条路径,最长路径的长度为树的深度. 牛客网上的剑指offer题, ...