結果

問題 No.542 1円玉と5円玉
ユーザー Charlotte8687Charlotte8687
提出日時 2018-12-03 14:17:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 4,847 ms
コンパイル使用メモリ 108,848 KB
実行使用メモリ 23,828 KB
最終ジャッジ日時 2023-09-13 21:08:31
合計ジャッジ時間 4,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
21,784 KB
testcase_01 AC 63 ms
23,684 KB
testcase_02 AC 63 ms
19,616 KB
testcase_03 AC 62 ms
21,692 KB
testcase_04 AC 64 ms
21,772 KB
testcase_05 AC 66 ms
23,668 KB
testcase_06 AC 66 ms
23,768 KB
testcase_07 AC 67 ms
23,784 KB
testcase_08 AC 67 ms
23,828 KB
testcase_09 AC 68 ms
21,716 KB
testcase_10 AC 64 ms
21,772 KB
testcase_11 AC 65 ms
23,828 KB
testcase_12 AC 67 ms
23,804 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace StudyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Trim().Split(' ');
            int oneCoin = int.Parse(inputs[0]);
            int fiveCoin = int.Parse(inputs[1]);

            var results = GetCombination(oneCoin, fiveCoin).Distinct().OrderBy(data => data);
            foreach (var result in results)
                Console.WriteLine(result);
        }

        private static IEnumerable<int> GetCombination(int oneCoin, int fiveCoin)
        {
            for (int i = 0; i <= fiveCoin; i++)
            {
                for (int j = 0; j <= oneCoin; j++)
                {
                    int total = i * 5 + j;
                    if (total != 0)
                        yield return total;
                }
            }
        }
    }
}
0