/** * */ package com.xingbing.lanqiao; import java.util.Scanner; /** * @author * @data * @description */ public class 小动物的逃逸 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt();//表示球的数量 int m = in.nextInt();//表示小动物的数量 int a[][] = new int[n][4];//用来保存球的坐标和半径 int b[][] = new int[m][3];//用来保存小动物的坐标 for(int i=0;i<n;i++){ for(int j=0;j<4;j++){ a[i][j] = in.nextInt(); } } for(int i=0;i<m;i++){ for(int j=0;j<3;j++){ b[i][j] = in.nextInt(); } } int count = 0; for(int i=0;i<m;i++){ count=0; for(int j=0;j<n;j++){ double r = (Math.pow(a[j][0]-b[i][0], 2)+Math.pow(a[j][1]-b[i][1], 2)+Math.pow(a[j][2]-b[i][2], 2)); if(r<Math.pow(a[j][3], 2)){ count++; } } System.out.print(count+" "); } } }
原文:https://www.cnblogs.com/xuesujun/p/12685861.html