結果

問題 No.52 よくある文字列の問題
ユーザー kou6839kou6839
提出日時 2015-02-06 16:34:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 77,596 KB
実行使用メモリ 58,612 KB
最終ジャッジ日時 2023-10-22 03:57:42
合計ジャッジ時間 4,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
58,376 KB
testcase_01 AC 160 ms
58,136 KB
testcase_02 AC 190 ms
58,604 KB
testcase_03 AC 163 ms
58,144 KB
testcase_04 AC 178 ms
58,608 KB
testcase_05 AC 185 ms
58,496 KB
testcase_06 AC 187 ms
58,612 KB
testcase_07 AC 179 ms
58,316 KB
testcase_08 AC 161 ms
58,404 KB
testcase_09 AC 156 ms
58,144 KB
testcase_10 AC 157 ms
58,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

public class Main {
	static Set<String> ans;
	static void dfs(String to,String moto){
		if(moto.equals("")){
			ans.add(to);
			return;
		}
		String temp = to + moto.charAt(0);
		dfs(temp, moto.substring(1,moto.length()));
		temp=to+moto.charAt(moto.length()-1);
		dfs(temp, moto.substring(0,moto.length()-1));
		
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ans=new HashSet<>();
        String string = sc.next();
        dfs("", string);
        System.out.println(ans.size());
    }
}			
0