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; count += y % m; } if(x != 0) { count++; if(x < 0) { x *= -1; } count += x / m; count += x % m; } if(y < 0) { count++; count += y / m; count += y % m; } Console.WriteLine(count); } }