結果
問題 |
No.238 Mr. K's Another Gift
|
ユーザー |
![]() |
提出日時 | 2018-02-22 16:26:15 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,103 bytes |
コンパイル時間 | 2,446 ms |
コンパイル使用メモリ | 78,236 KB |
実行使用メモリ | 64,336 KB |
最終ジャッジ日時 | 2024-10-01 20:36:09 |
合計ジャッジ時間 | 6,885 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 5 TLE * 1 -- * 34 |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { StringBuilder sb = new StringBuilder(sc.next()); String ans = "NA"; if (sb.length()%2==0) { String s = sb.toString(); String str = sb.insert(sb.length()/2,"a").reverse().toString(); sb.setLength(0); sb.append(s); for (int i=0; i<=sb.length(); i++) { s = sb.toString(); sb.insert(i,str.charAt(i)); String s2 = sb.toString(); if (sb.reverse().toString().equals(s2)) {ans=sb.toString(); break;} sb.setLength(0); sb.append(s); } } else if (sb.length()%2!=0) { String s = sb.toString(); String str = sb.insert(sb.length()/2,sb.charAt(sb.length()/2)).reverse().toString(); sb.setLength(0); sb.append(s); for (int i=0; i<=sb.length(); i++) { s = sb.toString(); sb.insert(i,str.charAt(i)); String s2 = sb.toString(); if (sb.reverse().toString().equals(s2)) {ans=sb.toString(); break;} sb.setLength(0); sb.append(s); } } System.out.println(ans); } }