結果

問題 No.542 1円玉と5円玉
ユーザー noriocnorioc
提出日時 2017-07-15 20:28:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 112,336 KB
実行使用メモリ 28,428 KB
最終ジャッジ日時 2024-04-16 21:53:35
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
26,008 KB
testcase_01 AC 33 ms
28,288 KB
testcase_02 AC 32 ms
26,520 KB
testcase_03 AC 32 ms
26,120 KB
testcase_04 AC 34 ms
26,004 KB
testcase_05 AC 33 ms
26,392 KB
testcase_06 AC 35 ms
26,780 KB
testcase_07 AC 36 ms
26,392 KB
testcase_08 AC 36 ms
26,136 KB
testcase_09 AC 36 ms
28,328 KB
testcase_10 AC 34 ms
26,260 KB
testcase_11 AC 35 ms
26,264 KB
testcase_12 AC 36 ms
28,428 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;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Calc(int a, int b) {
        var hs = new HashSet<int>();
        for (int i = 1; i <= a; i++)
            hs.Add(i);

        for (int i = 1; i <= b; i++)
            hs.Add(i * 5);

        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                if (i == 0 && j == 0) continue;
                hs.Add(i + j * 5);
            }
        }

        foreach (var e in hs.OrderBy(e => e)) {
            Console.WriteLine(e);
        }
    }

    static void Main() {
        var ab = ReadInts();
        int a = ab[0], b = ab[1];
        Calc(a, b);
    }
}
0