結果

問題 No.238 Mr. K's Another Gift
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 18:11:07
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 2,504 ms
コンパイル使用メモリ 79,552 KB
実行使用メモリ 58,532 KB
最終ジャッジ日時 2024-04-09 23:51:42
合計ジャッジ時間 31,240 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
53,988 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 115 ms
54,116 KB
testcase_11 AC 113 ms
54,068 KB
testcase_12 AC 112 ms
53,816 KB
testcase_13 AC 139 ms
53,868 KB
testcase_14 AC 529 ms
54,396 KB
testcase_15 AC 1,194 ms
56,900 KB
testcase_16 AC 1,164 ms
56,688 KB
testcase_17 AC 1,174 ms
57,576 KB
testcase_18 AC 1,150 ms
56,692 KB
testcase_19 AC 1,179 ms
56,680 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 200 ms
56,736 KB
testcase_29 WA -
testcase_30 AC 112 ms
53,852 KB
testcase_31 AC 108 ms
53,520 KB
testcase_32 AC 118 ms
54,108 KB
testcase_33 AC 145 ms
54,236 KB
testcase_34 AC 985 ms
56,748 KB
testcase_35 AC 1,191 ms
57,404 KB
testcase_36 AC 1,193 ms
56,944 KB
testcase_37 AC 1,170 ms
56,888 KB
testcase_38 AC 1,155 ms
56,556 KB
testcase_39 AC 1,186 ms
56,600 KB
testcase_40 WA -
testcase_41 AC 118 ms
54,132 KB
testcase_42 AC 102 ms
52,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String str = sc.next();
		int n = str.length();
		ArrayList<Character> s = new ArrayList<>();
		for (int i=0; i<n; i++) {
			s.add(str.charAt(i));
		}
		
		boolean F = false;
		
		for (int i=0; i<=n; i++) {
			if (i<=n/2) {s.add(i,s.get(n-i-1));}
			else {s.add(i,s.get(n-i));}
			
			boolean b = true;
			for (int j=0; j<(n+1)/2; j++) {
				if (s.get(j)!=s.get(n-j-1)) {b=false; break;}
			}
			if (b==true) {F=true; break;}
			
			s.remove(i);
		}
		
		if (F==false) {System.out.println("NA");}
		else {
			StringBuilder ans = new StringBuilder();
			for (char c : s) {ans.append(c);}
			System.out.println(ans.toString());
		}
	}
}
0