using System; using System.Collections.Generic; using System.Linq; //YukiCoder373 かけ算と割った余り //http://yukicoder.me/problems/no/373 class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("1 2 3 4"); //2 } else if (InputPattern == "Input2") { WillReturn.Add("2 2 2 2"); //0 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray(); long A=wkArr[0]; long B = wkArr[1]; long C = wkArr[2]; long D = wkArr[3]; long Answer = (A * B) % D; Answer = (Answer * C) % D; Console.WriteLine(Answer); } }