結果

問題 No.2234 palindromer
ユーザー AsahiAsahi
提出日時 2023-03-03 22:22:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 3,497 ms
コンパイル使用メモリ 76,404 KB
実行使用メモリ 57,584 KB
最終ジャッジ日時 2023-10-18 02:31:33
合計ジャッジ時間 6,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,468 KB
testcase_01 AC 129 ms
57,372 KB
testcase_02 AC 129 ms
57,392 KB
testcase_03 AC 132 ms
57,584 KB
testcase_04 AC 133 ms
57,576 KB
testcase_05 AC 130 ms
57,356 KB
testcase_06 AC 130 ms
57,576 KB
testcase_07 AC 131 ms
57,200 KB
testcase_08 AC 130 ms
57,348 KB
testcase_09 AC 128 ms
57,484 KB
testcase_10 AC 126 ms
57,308 KB
testcase_11 AC 131 ms
57,464 KB
testcase_12 AC 132 ms
57,356 KB
testcase_13 AC 129 ms
57,400 KB
testcase_14 AC 127 ms
57,264 KB
testcase_15 AC 127 ms
57,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        StringBuilder sb = new StringBuilder(A);
        sb.reverse();
        String revA = sb.toString();
        int n = A.length();
        for (int i = 0; i < n; i++) {
            String subA = A.substring(i);
            String subRevA = revA.substring(0, n - i);
            if (subA.equals(subRevA)) {
                System.out.println(A + revA.substring(n - i));
                break;
            }
        }
        sc.close();
    }
}
0