using System; using System.Collections; using System.Collections.Generic; public class Program { public static void Main() { string line; while ((line = System.Console.ReadLine ()) != null) { // 注意 while 处理多个 case string[] tokens = line.Split(' '); int R = int.Parse(tokens[0]) * 2;//直径 int x = int.Parse(tokens[1]); int y = int.Parse(tokens[2]); int x1 = int.Parse(tokens[3]); int y1 = int.Parse(tokens[4]); int dx = Math.Abs(x1 - x); int dy = Math.Abs(y1 - y); double dis = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2)); int a = (dis % R) == 0? 0: 1; int result = (int)(dis / R + a); Console.WriteLine(result); } } }
计算两点之间直线距离,每步移动2r的距离,移动x步后有余数,则再移动一步即可,因为倒数两步可以按照三角移动,距离可以介于r到2r之间