結果

問題 No.539 インクリメント
ユーザー 明智重蔵明智重蔵
提出日時 2017-07-01 17:36:55
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 2,147 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 116,504 KB
実行使用メモリ 58,660 KB
最終ジャッジ日時 2024-04-15 08:03:05
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
31,064 KB
testcase_01 AC 328 ms
58,660 KB
testcase_02 RE -
testcase_03 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.RegularExpressions;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("yuki2006");
            WillReturn.Add("rng_58");
            WillReturn.Add("sugim48");
            WillReturn.Add("02/29/2016");
            WillReturn.Add("D programming language version 0.99");
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("7");
            WillReturn.Add("hoge999hoge");
            WillReturn.Add("73-23=49");
            WillReturn.Add("O(n^2 log n)");
            WillReturn.Add("hoge0003871hoge");
            WillReturn.Add("00000000000000000000000");
            WillReturn.Add("-0");
            WillReturn.Add("piyo");
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string[] SArr = InputList.Skip(1).ToArray();

        foreach (string EachStr in SArr) {
            string Answer = EachStr;
            MatchCollection Matches = Regex.Matches(EachStr, "[0-9]+");
            if (Matches.Count > 0) {
                Match LastMatch = Matches[Matches.Count - 1];
                int MatchStaInd = LastMatch.Index;
                int MatchLength = LastMatch.Length;
                string MatchStr = LastMatch.Value;

                int wkInt = int.Parse(MatchStr);
                string wkStr = (wkInt + 1).ToString();

                //桁数が減るのは認めない
                if (MatchStr.Length > wkStr.Length) {
                    wkStr = wkStr.PadLeft(MatchStr.Length, '0');
                }
                Answer = Answer.Remove(MatchStaInd, MatchLength);
                Answer = Answer.Insert(MatchStaInd, wkStr);
            }
            Console.WriteLine(Answer);
        }
    }
}
0