結果
| 問題 | 
                            No.721 Die tertia (ディエ・テルツィア)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-10-17 20:07:17 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 27 ms / 2,000 ms | 
| コード長 | 2,689 bytes | 
| コンパイル時間 | 2,810 ms | 
| コンパイル使用メモリ | 110,476 KB | 
| 実行使用メモリ | 18,176 KB | 
| 最終ジャッジ日時 | 2024-10-12 18:53:59 | 
| 合計ジャッジ時間 | 2,536 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
    public class Program
    {
        static void Main(string[] args)
        {
            new Program().Main2(Console.In, Console.Out);
        }
        public void Main2(TextReader reader, TextWriter writer)
        {
            var lastDays = new Dictionary<int, int>()   // 月ごとの最終日
            {
                { 1, 31 },
                { 2, 28 },
                { 3, 31 },
                { 4, 30 },
                { 5, 31 },
                { 6, 30 },
                { 7, 31 },
                { 8, 31 },
                { 9, 30 },
                { 10, 31 },
                { 11, 30 },
                { 12, 31 },
            };
            //-----------------------------
            // 初期入力
            //-----------------------------
            var date = reader.ReadLine().Split('/');
            var year = int.Parse(date[0]);
            var month = int.Parse(date[1]);
            var day = int.Parse(date[2]);
            //-----------------------------
            // うるう年の場合は29日に設定
            //-----------------------------
            if(CheckLeapYear(year))
            {
                lastDays[2] = 29;
            }
            //-----------------------------
            // メインロジック
            //-----------------------------
            day += 2;
            if (day > lastDays[month])
            {
                // 二日後、月をまたぐ場合は1月プラス
                day = day % lastDays[month];
                month++;
                if(month > 12)
                {
                    // 12月を超えた場合は1年プラス
                    month = month % 12;
                    year++;
                }
            }
            //-----------------------------
            // 結果確認
            //-----------------------------
            writer.WriteLine($"{year}/{month.ToString("D2")}/{day.ToString("D2")}");
        }
        /// <summary>
        /// うるう年判定
        /// </summary>
        /// <param name="year">年</param>
        /// <returns>true: うるう年 false: うるう年でない</returns>
        public bool CheckLeapYear(int year)
        {
            // 参考:http://tomoprog.hatenablog.com/entry/2016/03/01/004755
            if (year % 400 == 0) return true;
            if (year % 4 == 0 && year % 100 == 0) return false;
            if (year % 4 == 0) return true;
            return false;
        }
    }
}