結果

問題 No.52 よくある文字列の問題
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-28 18:49:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 860 bytes
コンパイル時間 3,267 ms
コンパイル使用メモリ 78,256 KB
実行使用メモリ 57,736 KB
最終ジャッジ日時 2023-10-22 04:06:04
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
57,420 KB
testcase_01 AC 140 ms
57,476 KB
testcase_02 AC 149 ms
57,616 KB
testcase_03 AC 137 ms
57,408 KB
testcase_04 AC 148 ms
57,664 KB
testcase_05 AC 147 ms
55,672 KB
testcase_06 AC 150 ms
57,696 KB
testcase_07 AC 146 ms
57,736 KB
testcase_08 AC 145 ms
57,660 KB
testcase_09 AC 136 ms
57,456 KB
testcase_10 AC 140 ms
57,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<String> set = new HashSet<>();
        String S = sc.next();
        String [] arr = S.split("");
        int L = S.length();
        int N = (int)Math.pow(2,L-1);
        for(int i=0; i<N; i++){
            String t = Integer.toBinaryString(i);
            while(t.length()<L-1){
                t="0"+t;
            }
            int f=0;
            int b=L-1;
            String p = "";
            for(int j=0; j<L-1; j++){
                if(t.charAt(j)=='0'){
                    p=p+arr[f];
                    f++;
                }else{
                    p=p+arr[b];
                    b--;
                }
            }
            set.add(p);
        }
        System.out.println(set.size());
    }
}
0