結果

問題 No.52 よくある文字列の問題
ユーザー samplelpmassamplelpmas
提出日時 2017-02-03 18:24:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 851 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 75,740 KB
実行使用メモリ 57,588 KB
最終ジャッジ日時 2023-10-22 04:06:43
合計ジャッジ時間 4,574 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,444 KB
testcase_01 AC 135 ms
57,444 KB
testcase_02 AC 146 ms
57,588 KB
testcase_03 AC 129 ms
57,516 KB
testcase_04 AC 142 ms
57,484 KB
testcase_05 AC 142 ms
57,424 KB
testcase_06 AC 141 ms
57,448 KB
testcase_07 AC 134 ms
57,404 KB
testcase_08 AC 137 ms
57,408 KB
testcase_09 AC 133 ms
57,500 KB
testcase_10 AC 135 ms
57,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        Set<String> hm = new HashSet<String>();

        for (int i = 0; i < (1 << S.length()); i++) {

            int left = 0;
            int right = S.length() - 1;

            StringBuilder sb = new StringBuilder();

            for (int j = 0; j < S.length(); j++) {

                if ((( i >> j) % 2 ) == 0) {

                    sb.append(S.charAt(left));
                    left++;

                } else {

                    sb.append(S.charAt(right));
                    right--;

                }

            }

            hm.add(sb.toString());

        }

        System.out.println(hm.size());

    }

}
0