using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; namespace AizuOnlineJudge { /// /// メインクラス 問題解答 /// public class Program { /// /// 実行関数 /// /// public static void Main(string[] args) { new CalcAmountMoney().Anser(); } } /// /// FizzBuzz出力クラス /// public class CalcAmountMoney { /// /// 入出力担当クラス 今回は答え出力用 /// ConsoleInput Input = new ConsoleInput(Console.In, ' '); /// /// ソート答え /// public void Anser() { List anserList = InsertionSort(GetAmountMoneyList()); foreach (var anser in anserList) Console.WriteLine(anser); } /// /// 計算しうる全ての値を格納したListを取得する /// /// public List GetAmountMoneyList() { var yen1 = Input.ReadInt; var yen5 = Input.ReadInt; var amountMoneyList = new List(); for (int i = 0; i <= yen1; i++) for (int r = 0; r <= yen5; r++) { if (amountMoneyList.Contains((i * 1) + (r * 5)) == true) continue; if ((i * 1) + (r * 5) == 0) continue; amountMoneyList.Add((i * 1) + (r * 5)); } return amountMoneyList; } /// /// 挿入ソート /// /// /// public List InsertionSort(List AmountMoneyList) { for (int i = 0; i < AmountMoneyList.Count; i++) { var targetValue = AmountMoneyList[i]; var comparisionIndex = i - 1; while (comparisionIndex >= 0 && targetValue < AmountMoneyList[comparisionIndex]) { AmountMoneyList[comparisionIndex + 1] = AmountMoneyList[comparisionIndex]; AmountMoneyList[comparisionIndex] = targetValue; comparisionIndex--; } } return AmountMoneyList; } } /// /// 標準入出力担当クラス /// public class ConsoleInput { /// /// ストリームからテキストを読み込む /// private readonly System.IO.TextReader Stream; /// /// 区分け文字 /// private char Separator = ' '; /// /// 読み取った入力値を格納する /// private Queue InputStream; /// /// コンストラクタ /// /// 使用するテキストリーダー /// 区分け文字 public ConsoleInput(System.IO.TextReader Stream, char Separator = ' ') { this.Separator = Separator; this.Stream = Stream; InputStream = new Queue(); } /// /// 入力値読込み /// public string Read { get { if (InputStream.Count != 0) { return InputStream.Dequeue(); } string[] splitStrs = Stream.ReadLine().Split(Separator); for (int i = 0; i < splitStrs.Length; ++i) { InputStream.Enqueue(splitStrs[i]); } return InputStream.Dequeue(); } } public string ReadLine { get { return Stream.ReadLine(); } } public int ReadInt { get { return int.Parse(Read); } } public long ReadLong { get { return long.Parse(Read); } } public double ReadDouble { get { return double.Parse(Read); } } public string[] ReadStrArray(long N) { var inputStrArray = new string[N]; for (long i = 0; i < N; ++i) { inputStrArray[i] = Read; } return inputStrArray; } public int[] ReadIntArray(long N) { var inputIntArray = new int[N]; for (long i = 0; i < N; ++i) { inputIntArray[i] = ReadInt; } return inputIntArray; } public long[] ReadLongArray(long N) { var inputLongArray = new long[N]; for (long i = 0; i < N; ++i) { inputLongArray[i] = ReadLong; } return inputLongArray; } /// /// Separator区切りでAnserListの要素を一行に出力する /// /// /// public void OutPut(List AnserList, char Separator) where T : struct { for (int i = 0; i < AnserList.Count; i++) { if (i != AnserList.Count - 1) Console.Write(AnserList[i] + " "); else Console.Write(AnserList[i]); } Console.Write("\n"); } } }