結果
問題 | No.52 よくある文字列の問題 |
ユーザー |
![]() |
提出日時 | 2016-11-28 18:49:07 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 139 ms / 5,000 ms |
コード長 | 860 bytes |
コンパイル時間 | 2,163 ms |
コンパイル使用メモリ | 77,672 KB |
実行使用メモリ | 54,384 KB |
最終ジャッジ日時 | 2024-09-22 05:27:53 |
合計ジャッジ時間 | 4,234 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
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()); } }