結果

問題 No.539 インクリメント
ユーザー NoNo
提出日時 2017-07-30 16:56:39
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,299 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 100,768 KB
実行使用メモリ 37,964 KB
最終ジャッジ日時 2023-08-01 06:20:24
合計ジャッジ時間 3,005 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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.Linq;

namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
            {
                string s = Console.ReadLine();
                int nn = s.Length - 1;
                for (int j = s.Length - 1; j >= 0; j--)
                {
                    if ('0' <= s[j] && s[j] <= '9')
                    {

                    }
                    else
                    {
                        nn = j + 1;
                        break;
                    }
                }

                string ns = "";
                bool f = false;
                if (nn != s.Length)
                {
                    int newNum = int.Parse(s.Substring(nn)) + 1;
                    if (newNum.ToString().Length != s.Substring(nn).Length)
                    {
                        f = true;
                    }
                    ns = newNum.ToString();
                }

                int aaa = ns.Length;
                if (f)
                {
                    aaa--;
                }
                string ans = s.Substring(0, s.Length - aaa) + ns;
                Console.WriteLine(ans);
            }
        }
    }
}
0