首页 技术 正文
技术 2022年11月8日
0 收藏 799 点赞 1,713 浏览 2423 个字

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 3C++期末考试题。。。
基本输入输出,傻了。
那个括号完全可以当作字符输入然后不管他的嘤嘤嘤。
强行用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 ;
}

    					
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,112
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,585
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,922