結果
| 問題 | No.542 1円玉と5円玉 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-06-10 13:29:52 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 5,827 bytes |
| コンパイル時間 | 1,074 ms |
| コンパイル使用メモリ | 107,264 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-10-06 00:35:56 |
| 合計ジャッジ時間 | 1,900 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace AizuOnlineJudge
{
/// <summary>
/// メインクラス 問題解答
/// </summary>
public class Program
{
/// <summary>
/// 実行関数
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args)
{
new CalcAmountMoney().Anser();
}
}
/// <summary>
/// FizzBuzz出力クラス
/// </summary>
public class CalcAmountMoney
{
/// <summary>
/// 入出力担当クラス 今回は答え出力用
/// </summary>
ConsoleInput Input = new ConsoleInput(Console.In, ' ');
/// <summary>
/// ソート答え
/// </summary>
public void Anser()
{
List<int> anserList = InsertionSort(GetAmountMoneyList());
foreach (var anser in anserList)
Console.WriteLine(anser);
}
/// <summary>
/// 計算しうる全ての値を格納したListを取得する
/// </summary>
/// <returns></returns>
public List<int> GetAmountMoneyList()
{
var yen1 = Input.ReadInt;
var yen5 = Input.ReadInt;
var amountMoneyList = new List<int>();
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;
}
/// <summary>
/// 挿入ソート
/// </summary>
/// <param name="AmountMoneyList"></param>
/// <returns></returns>
public List<int> InsertionSort(List<int> 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;
}
}
/// <summary>
/// 標準入出力担当クラス
/// </summary>
public class ConsoleInput
{
/// <summary>
/// ストリームからテキストを読み込む
/// </summary>
private readonly System.IO.TextReader Stream;
/// <summary>
/// 区分け文字
/// </summary>
private char Separator = ' ';
/// <summary>
/// 読み取った入力値を格納する
/// </summary>
private Queue<string> InputStream;
/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="Stream">使用するテキストリーダー</param>
/// <param name="Separator">区分け文字</param>
public ConsoleInput(System.IO.TextReader Stream, char Separator = ' ')
{
this.Separator = Separator;
this.Stream = Stream;
InputStream = new Queue<string>();
}
/// <summary>
/// 入力値読込み
/// </summary>
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;
}
/// <summary>
/// Separator区切りでAnserListの要素を一行に出力する
/// </summary>
/// <param name="AnserList"></param>
/// <param name="Separator"></param>
public void OutPut<T>(List<T> 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");
}
}
}