using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("AO"); WillReturn.Add("BO"); } else if (InputPattern == "Input2") { WillReturn.Add("AB"); WillReturn.Add("OO"); } else if (InputPattern == "Input3") { WillReturn.Add("AO"); WillReturn.Add("AB"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); string S = InputList[0]; string T = InputList[1]; int Bunbo = S.Length * T.Length; var CntDict = new Dictionary(); CntDict["A"] = 0; CntDict["B"] = 0; CntDict["AB"] = 0; CntDict["O"] = 0; foreach (char EachChar1 in S) { foreach (char EachChar2 in T) { string BloodType = DeriveBloodType(EachChar1.ToString(), EachChar2.ToString()); CntDict[BloodType]++; } } Console.WriteLine("{0} {1} {2} {3}", CntDict["A"] * 100 / Bunbo, CntDict["B"] * 100 / Bunbo, CntDict["AB"] * 100 / Bunbo, CntDict["O"] * 100 / Bunbo); } // 文字列を引数として、血液型を返す static string DeriveBloodType(string p1, string p2) { string ConcatStr = p1 + p2; if (ConcatStr.Contains("A") && ConcatStr.Contains("B") == false) { return "A"; } if (ConcatStr.Contains("B") && ConcatStr.Contains("A") == false) { return "B"; } if (ConcatStr.Contains("A") && ConcatStr.Contains("B")) { return "AB"; } return "O"; } }