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折优惠券,这样的广告 ...
随机推荐
- Java基础知识点简记
此篇主要记录(搬运)的是Java中一些常见概念的理解,大致内容如下 final.finally.finalize的区别 Java的传值或者传引用的理解 重写Override和重载Overload的理解 ...
- Unity获取游戏对象详解
我觉得Unity里面的Transform 和 GameObject就像两个双胞胎兄弟一样,这俩哥们很要好,我能直接找到你,你也能直接找到我.我看很多人喜欢在类里面去保存GameObject对象.解决G ...
- PAT Advanced 1053 Path of Equal Weight (30) [树的遍历]
题目 Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight ...
- split和join合写
小骆驼 第一章 简介 1. // input 和截取字符 #!usr/bin/perl use strict; use warnings; while ( <> ) { chomp; pr ...
- Linux 基本操作学习
Linux 学习 虚拟机 (Virtual Machine) 指通过软件模拟的具有完整硬件系统功能的,运行再一个完全隔离环境中的完整计算机系统 常用 Linux 命令 命令 对应英文 作用 ls li ...
- centos挂载磁盘
Aliyun实例为例 简单操作: 查看磁盘情况:fdisk -l 对数据盘进行分区,一般类似/dev/vdb这种为数据盘 输入fdisk /dev/vdb 对数据盘进行分区.根据提示,输入 n, p ...
- AES学习小结
AES是基于数据块的加密方式,即每次处理的数据是一块(16字节),当数据不是16字节的倍数时填充,这就是所谓的分组密码(区别于基于比特位的流密码),16字节是分组长度. AES支持五种模式:CBC,C ...
- JNI的第1种写法 及 JNI通过形参修改Java数据
声明:迁移自本人CSDN博客https://blog.csdn.net/u013365635 目的:通过形参在Java 和C之间传递数据,尤其是大块的媒体数据 优点:避免通过返回值返回一个巨大的数据块 ...
- 201312-1 出现次数最多的数Java
import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; ...
- CocoaPods-Alcatraz插件
Alcatraz:Xcode的插件管理工具,可通过它添加CocoaPods插件 下载地址:https://github.com/alcatraz/Alcatraz 建议: 不提倡通过终端命令下载Alc ...