結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー moriguchi1983moriguchi1983
提出日時 2018-10-10 21:23:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,829 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 104,832 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-04-20 19:30:29
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
17,792 KB
testcase_01 AC 22 ms
17,792 KB
testcase_02 AC 22 ms
17,792 KB
testcase_03 AC 22 ms
17,920 KB
testcase_04 AC 21 ms
17,920 KB
testcase_05 AC 22 ms
18,048 KB
testcase_06 AC 22 ms
17,792 KB
testcase_07 AC 21 ms
18,048 KB
testcase_08 AC 22 ms
17,792 KB
testcase_09 AC 22 ms
17,792 KB
testcase_10 AC 22 ms
17,792 KB
testcase_11 AC 20 ms
17,664 KB
testcase_12 AC 21 ms
17,920 KB
testcase_13 AC 21 ms
17,920 KB
testcase_14 AC 21 ms
17,792 KB
testcase_15 AC 21 ms
17,792 KB
testcase_16 AC 22 ms
17,664 KB
testcase_17 AC 21 ms
17,792 KB
testcase_18 AC 23 ms
17,792 KB
testcase_19 AC 21 ms
17,920 KB
testcase_20 AC 21 ms
17,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace Probrem043
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            var input = Console.ReadLine().Split('/');
            var year = int.Parse(input[0]); //2000
            var month = int.Parse(input[1]); //01
            var day = int.Parse(input[2]); //01
            
            //解ロジック         
            day += 2;       //2日足す

            //月・日の計算
            var monthOfDays = monthCheck(year, month);
            if (day > monthOfDays) {
                month++;
                day = day - monthOfDays;
            }
            //年・月の計算
            if (month > 12) {
                year++;
                month = 1;
            }

            //出力
            var answer = String.Format("{0:0000}/{1:00}/{2:00}", year, month, day);
            Console.WriteLine(answer);
        }

        //monthは何日か?
        static int monthCheck(int year,int month) {
            var thirty = new[] { 4,6,9,11};
            foreach (var tOne in thirty) {
                if (month == tOne) {
                    return 30;
                }
            }

            if (month == 2) {
                if (IsLeapYear(year)) {
                    return 29;
                }else { 
                    return 28;
                }
            }
            return 31;
        }

        //うるう年かどうか?
        static bool IsLeapYear(int year) { 
            if(year % 4 == 0){
	            if(year % 100 == 0){
		            if(year % 400 == 0){
			            return true;
		            }else{
			            return false;
		            }
	            }else{
		            return true;
	            }
            }else{
	            return false;
            }
        }
    }
}
0