結果
問題 |
No.52 よくある文字列の問題
|
ユーザー |
![]() |
提出日時 | 2014-12-15 13:13:42 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 144 ms / 5,000 ms |
コード長 | 670 bytes |
コンパイル時間 | 2,133 ms |
コンパイル使用メモリ | 75,524 KB |
実行使用メモリ | 54,312 KB |
最終ジャッジ日時 | 2024-09-22 05:18:54 |
合計ジャッジ時間 | 4,222 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
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()); } }