結果

問題 No.188 HAPPY DAY
ユーザー ttttstttts
提出日時 2020-02-21 15:56:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 20 ms / 1,000 ms
コード長 3,547 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 107,264 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-04-17 06:45:06
合計ジャッジ時間 1,392 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
17,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

    class Program
    {
        static void Main(string[] args)
        {

            int cnt = 0;

            for (int i=1; i<=12; i++)
            {
                switch (i)
                {
                    case 1:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 2:
                        for (int j= 1; j <= 28; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 3:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 4:
                        for (int j = 1; j <= 30; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 5:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 6:
                        for (int j = 1; j <= 30; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 7:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 8:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 9:
                        for (int j = 1; j <= 30; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 10:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 11:
                        for (int j = 1; j <= 30; j++)
                        {
                            calc(i, j);
                        }
                        break;
                    case 12:
                        for (int j = 1; j <= 31; j++)
                        {
                            calc(i, j);
                        }
                        break;
                }
         
            }


            Console.WriteLine(cnt);

            void calc(int num1, int num2)
            {
                int month = num1;
                string strday = num2.ToString();
                if (strday.Length == 2)
                {
                    char[] day = strday.ToCharArray();
                    int day1 = int.Parse(day[0].ToString());
                    int day2 = int.Parse(day[1].ToString());

                    if (month == day1 + day2)
                    {
                        cnt++;
                    }
                }
                else if (strday.Length == 1)
                {
                    int day1 = int.Parse(strday);
                    if (month == day1)
                    {
                        cnt++;
                    }
                }

            }
        }

    }
0