結果

問題 No.188 HAPPY DAY
ユーザー NoNo
提出日時 2015-04-22 00:40:10
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 2,540 bytes
コンパイル時間 1,954 ms
コンパイル使用メモリ 104,628 KB
実行使用メモリ 20,696 KB
最終ジャッジ日時 2023-08-29 01:49:46
合計ジャッジ時間 2,473 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,696 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;
using System.Text;
using System.Threading.Tasks;

namespace ForYukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int cnt = 0;

            //1
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(1, i) == true) cnt++;
            }

            //2
            for (int i = 1; i <= 29; i++)
            {
                if (isHappy(2, i) == true) cnt++;
            }

            //3
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(3, i) == true) cnt++;
            }

            //4
            for (int i = 1; i <= 30; i++)
            {
                if (isHappy(4, i) == true) cnt++;
            }

            //5
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(5, i) == true) cnt++;
            }

            //6
            for (int i = 1; i <= 30; i++)
            {
                if (isHappy(6, i) == true) cnt++;
            }

            //7
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(7, i) == true) cnt++;
            }

            //8
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(8, i) == true) cnt++;
            }

            //9
            for (int i = 1; i <= 30; i++)
            {
                if (isHappy(9, i) == true) cnt++;
            }

            //10
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(10, i) == true) cnt++;
            }

            //11
            for (int i = 1; i <= 30; i++)
            {
                if (isHappy(11, i) == true) cnt++;
            }

            //12
            for (int i = 1; i <= 31; i++)
            {
                if (isHappy(12, i) == true) cnt++;
            }

            Console.WriteLine(cnt);
            Console.ReadLine();
        }

        static bool isHappy(int month, int day)
        {
            string strDay = day.ToString();
            string strDay2;
            string strDay3;
            int a;

            if (strDay.Length == 2)
            {
                strDay2 = strDay.Substring(0, 1);
                strDay3 = strDay.Substring(1, 1);
                a = int.Parse(strDay2) + int.Parse(strDay3);
            }
            else
            {
                a = int.Parse(strDay.Substring(0, 1));
            }

            return (month == a) ? true : false;
        }
    }
}
0