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折优惠券,这样的广告 ...
随机推荐
- Navicat Premium 12.0.18 安装与激活
Navicat Premium 12.0.18中文版 百度云链接:https://pan.baidu.com/s/1HHOOlQbbWAL-MlI908n4MQ 提取码:k9w6 1.下载好后双击运行 ...
- “帮你”校园资讯平台app使用体验
该app由我的17级学长学姐编写而成,主要功能失物招领,二手市场,表白墙.该软件目前只是面向本校的各专业学生,为内测版本.该软件的注册流程简单,只需要学号确定身份后即可登陆,并且发布各种信息,或者与丢 ...
- UVA 11922 伸展树Splay 第一题
上次ZOJ月赛碰到一个题目要求对序列中的某个区间求gcd,并且还要随时对某位数字进行修改 插入 删除,当时马上联想到线段树,但是线段树不支持增删,明显还是不可以的,然后就敲了个链表想暴力一下,结果TL ...
- Python说文解字_杂谈01
1. Python在Ubuntu下面下载Python 2. 安装依赖包 sudo apt-get update sudo apt-get install build-essential python- ...
- 面试易错题 Java
1. int[] arr = new int[10]; System.out.println(arr);//地址值? char[] arr1 = new char[10]; System.out.pr ...
- 阿里云服务器下安装配置phpMyAdmin
1.下载phpMyAdmin wget http://www.phpmyadmin.net/home_page/downloads.php 2.解压下载的文件 tar -zvxf phpMyAdmin ...
- Facebook的Libra “区块链”到底是如何运作的?
本文深入研究了"关于Facebook Libra coin (以及更多)平台协议"的26页技术文档,并对其内容进行了分解说明.同时,我们对这53位作者表示衷心的钦佩! 以下为具体分 ...
- Mybatis 使用分页查询亿级数据 性能问题 DB使用ORACLE
一般用到了mybatis框架分页就不用自己写了 直接用RowBounds对象就可以实现,但这个性能确实很低 今天我用到10w级得数据分页查询,到后面几页就迭代了很慢 用于记录 1.10万级数据如下 [ ...
- POJ-2561 Network Saboteur(DFS)
题目: A university network is composed of N computers. System administrators gathered information on t ...
- 寒假day03-python
今天完成了毕设登录注册.填报等功能的界面优化,同时总结了python网络课程的部分知识点 1.修改jupyter notebook默认路径:进入cmd:(1)cd /d F:\(2)jupyter n ...