結果

問題 No.238 Mr. K's Another Gift
ユーザー HIROPON87069639HIROPON87069639
提出日時 2016-02-22 21:47:52
言語 Python2
(2.7.18)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 7,088 KB
実行使用メモリ 7,304 KB
最終ジャッジ日時 2023-10-23 19:21:41
合計ジャッジ時間 2,880 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,432 KB
testcase_01 AC 11 ms
6,432 KB
testcase_02 AC 10 ms
6,432 KB
testcase_03 AC 11 ms
6,432 KB
testcase_04 AC 11 ms
6,496 KB
testcase_05 AC 19 ms
7,148 KB
testcase_06 AC 19 ms
7,304 KB
testcase_07 AC 24 ms
7,304 KB
testcase_08 AC 24 ms
7,304 KB
testcase_09 AC 33 ms
7,304 KB
testcase_10 AC 11 ms
6,432 KB
testcase_11 AC 11 ms
6,432 KB
testcase_12 AC 11 ms
6,432 KB
testcase_13 AC 10 ms
6,444 KB
testcase_14 AC 18 ms
6,784 KB
testcase_15 AC 29 ms
7,304 KB
testcase_16 AC 29 ms
7,304 KB
testcase_17 AC 13 ms
7,304 KB
testcase_18 AC 16 ms
7,304 KB
testcase_19 AC 13 ms
7,304 KB
testcase_20 AC 11 ms
6,432 KB
testcase_21 AC 11 ms
6,432 KB
testcase_22 AC 11 ms
6,432 KB
testcase_23 AC 11 ms
6,432 KB
testcase_24 AC 13 ms
6,480 KB
testcase_25 AC 13 ms
6,520 KB
testcase_26 AC 19 ms
7,304 KB
testcase_27 AC 30 ms
7,304 KB
testcase_28 AC 19 ms
7,304 KB
testcase_29 AC 31 ms
7,304 KB
testcase_30 AC 11 ms
6,432 KB
testcase_31 AC 10 ms
6,432 KB
testcase_32 AC 10 ms
6,432 KB
testcase_33 AC 11 ms
6,508 KB
testcase_34 AC 13 ms
7,216 KB
testcase_35 AC 27 ms
7,304 KB
testcase_36 AC 16 ms
7,304 KB
testcase_37 AC 18 ms
7,304 KB
testcase_38 AC 16 ms
7,304 KB
testcase_39 AC 13 ms
7,304 KB
testcase_40 AC 10 ms
6,432 KB
testcase_41 AC 11 ms
6,432 KB
testcase_42 AC 11 ms
6,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

def kai(S):
    cnts = 0
    cntf = len(S)-1
    while cnts <= cntf :
        if S[cnts] != S[cntf]:
            return 0
        cnts += 1
        cntf -= 1
    return 1



S = list(raw_input())
if len(S) == 1:
    print "".join(S*2)
    exit()
if kai(S):
    n = len(S) / 2
    S.insert(n ,S[n])
    print "".join(S)
    exit()

cnts = 0
cntf = len(S)-1
while cnts <= cntf :
    if S[cnts] != S[cntf]:
        if S[cnts +1] == S[cntf]:
            S.insert(cntf+1, S[cnts])
            if kai(S):
                print "".join(S)
                exit()
            else:
                print "NA"
                exit()
        elif S[cnts] == S[cntf-1]:
            S.insert(cnts, S[cntf])
            if kai(S):
                print "".join(S)
                exit()
            else:
                print "NA"
                exit()
        else:
            print "NA"
            exit()
    cnts += 1
    cntf -= 1
0