結果

問題 No.539 インクリメント
ユーザー mbanmban
提出日時 2017-07-11 18:57:01
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,578 bytes
コンパイル時間 1,082 ms
コンパイル使用メモリ 106,880 KB
実行使用メモリ 38,660 KB
最終ジャッジ日時 2024-04-16 17:03:42
合計ジャッジ時間 2,515 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int T;

    private string Func(string s)
    {
        var c = s.ToList();
        for (int i = c.Count - 1; i >= 0; i--)
        {
            if ('0' <= c[i] && c[i] <= '9')
            {
                int j;
                bool p = true;
                for (j = i; j >= 0 && p; j--)
                {
                    if (!('0' <= c[j] && c[j] <= '9'))
                    {
                        break;
                    }
                    if (c[j] == '9')
                    {
                        c[j] = '0';
                    }
                    else
                    {
                        c[j]++;
                        p = false;
                        break;
                    }
                }
                if (p)
                {
                    c.Insert(j + 1, '1');
                }
                break;
            }
        }
        return new string(c.ToArray());
    }

    private void Scan()
    {
        T = int.Parse(Console.ReadLine());
    }

    public void Solve()
    {
        Scan();
        var sb = new StringBuilder();
        for (int i = 0; i < T; i++)
        {
            sb.AppendLine(Func(Console.ReadLine()));
        }
        Console.WriteLine(sb.ToString());
    }
}
0