結果

問題 No.188 HAPPY DAY
ユーザー meimaruEngineermeimaruEngineer
提出日時 2019-02-13 12:18:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 1,270 bytes
コンパイル時間 3,660 ms
コンパイル使用メモリ 102,252 KB
実行使用メモリ 22,472 KB
最終ジャッジ日時 2023-10-11 11:09:01
合計ジャッジ時間 2,678 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
22,472 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;

public class Hello
{
    static int happyDayCount = 0;
    static int month = 1;

    public static void Main()
    {
        int day = 0;


        //string[] input = Console.ReadLine().Split(' ');
        while (month < 12)
        {
            day = DecideDay(month);
            CalculateHappyDay(day);
            month++;
        }
        Console.WriteLine(happyDayCount);
    }

    public static int DecideDay(int month)
    {
        int day = 0;

        switch (month)
        {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                day = 31;
                break;

            case 4:
            case 6:
            case 9:
            case 11:
                day = 30;
                break;

            case 2:
                day = 28;
                break;
        }
        return day;
    }
    public static void CalculateHappyDay(int day)
    {
        for (int i = 1; i <= day; i++)
        {
            int onesPlace = i % 10;
            int tensPlace = i / 10;
            if (month.Equals(onesPlace + tensPlace))
            {
                happyDayCount++;
            }
        }
    }
}
0