結果

問題 No.238 Mr. K's Another Gift
ユーザー NoNo
提出日時 2017-05-24 21:40:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,523 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 109,488 KB
実行使用メモリ 25,996 KB
最終ジャッジ日時 2023-10-19 22:37:09
合計ジャッジ時間 4,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,408 KB
testcase_01 AC 29 ms
24,776 KB
testcase_02 AC 28 ms
24,848 KB
testcase_03 AC 31 ms
24,844 KB
testcase_04 AC 26 ms
24,376 KB
testcase_05 AC 37 ms
25,728 KB
testcase_06 AC 26 ms
24,376 KB
testcase_07 AC 36 ms
25,992 KB
testcase_08 AC 36 ms
25,992 KB
testcase_09 AC 37 ms
25,992 KB
testcase_10 AC 31 ms
24,776 KB
testcase_11 AC 28 ms
24,836 KB
testcase_12 AC 32 ms
24,848 KB
testcase_13 AC 33 ms
24,852 KB
testcase_14 AC 33 ms
25,108 KB
testcase_15 AC 36 ms
25,992 KB
testcase_16 AC 41 ms
25,992 KB
testcase_17 AC 39 ms
25,992 KB
testcase_18 AC 36 ms
25,992 KB
testcase_19 AC 35 ms
25,996 KB
testcase_20 AC 30 ms
24,768 KB
testcase_21 AC 30 ms
24,832 KB
testcase_22 AC 26 ms
24,408 KB
testcase_23 AC 30 ms
24,844 KB
testcase_24 AC 29 ms
24,848 KB
testcase_25 AC 31 ms
24,848 KB
testcase_26 AC 28 ms
24,376 KB
testcase_27 AC 37 ms
25,992 KB
testcase_28 AC 28 ms
24,376 KB
testcase_29 AC 36 ms
25,992 KB
testcase_30 AC 29 ms
24,832 KB
testcase_31 AC 29 ms
24,848 KB
testcase_32 AC 30 ms
24,844 KB
testcase_33 AC 32 ms
24,848 KB
testcase_34 AC 34 ms
25,832 KB
testcase_35 AC 36 ms
25,992 KB
testcase_36 AC 35 ms
25,992 KB
testcase_37 AC 37 ms
25,992 KB
testcase_38 AC 39 ms
25,992 KB
testcase_39 AC 36 ms
25,996 KB
testcase_40 AC 30 ms
24,832 KB
testcase_41 AC 26 ms
24,408 KB
testcase_42 AC 29 ms
24,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Yuki
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int i = 0;
            int j = s.Length - 1;
            int c = -1;
            int d = -1;

            bool f = true;
            while (i <= j)
            {
                if (s[i] != s[j])
                {
                    c = i;
                    d = j;
                    f = false;
                    break;
                }
                i++;
                j--;
            }

            if (f)
            {
                Console.Write(s.Insert(s.Length / 2, s[s.Length / 2].ToString()));
            }
            else
            {
                string a = s.Insert(c, s[d].ToString());
                string b = "";
                if (c == 0)
                {
                    b = s + s[0];
                }
                else
                {
                    b = s.Insert(d + 1, s[c].ToString());
                }
                string a2 = new string(a.Reverse().ToArray());
                string b2 = new string(b.Reverse().ToArray());


                if (a == a2)
                {
                    Console.WriteLine(a);
                }
                else if (b == b2)
                {
                    Console.WriteLine(b);
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }
        }
    }
}
0