結果

問題 No.52 よくある文字列の問題
ユーザー ぴろずぴろず
提出日時 2014-12-15 13:13:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 670 bytes
コンパイル時間 3,303 ms
コンパイル使用メモリ 84,468 KB
実行使用メモリ 57,552 KB
最終ジャッジ日時 2023-10-22 03:57:00
合計ジャッジ時間 4,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
57,048 KB
testcase_01 AC 134 ms
57,032 KB
testcase_02 AC 147 ms
57,380 KB
testcase_03 AC 137 ms
57,328 KB
testcase_04 AC 146 ms
57,336 KB
testcase_05 AC 144 ms
57,160 KB
testcase_06 AC 148 ms
57,396 KB
testcase_07 AC 137 ms
57,552 KB
testcase_08 AC 136 ms
57,312 KB
testcase_09 AC 136 ms
57,404 KB
testcase_10 AC 132 ms
57,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no052;

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		HashSet<String> hm = new HashSet<>();
		for(int i=0;i<(1<<n);i++) {
			int head = 0;
			int tail = n - 1;
			StringBuilder sb = new StringBuilder();
			for(int j=0;j<n;j++) {
				if (((i>>j)&1) == 0) {
					sb.append(s[head]);
					head++;
				}else{
					sb.append(s[tail]);
					tail--;
				}
			}
//			System.out.println(sb.toString());
			hm.add(sb.toString());
		}
		System.out.println(hm.size());
	}
}
0