using System; public class Program { public static void Main() { int x = int.Parse(Console.ReadLine() ?? string.Empty); int y = int.Parse(Console.ReadLine() ?? string.Empty); int m = int.Parse(Console.ReadLine() ?? string.Empty); //string[] pass = (Console.ReadLine() ?? string.Empty).Trim().Split(' '); //string a = Console.ReadLine() ?? string.Empty; int count = 0; if (y > 0) //北向きそのまま前進 { count += y / m; if (y % m != 0) { count++; } } if (x != 0) { count++; if (x < 0) { x *= -1; } count += x / m; if (x % m != 0) { count++; } } if (y < 0) { if (x == 0) { count++; } count++; y *= -1; count += y / m; if (y % m != 0) { count++; } } Console.WriteLine(count); } }