結果

問題 No.52 よくある文字列の問題
ユーザー mosmos_21mosmos_21
提出日時 2017-06-19 08:44:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 536 bytes
コンパイル時間 2,385 ms
コンパイル使用メモリ 77,956 KB
実行使用メモリ 58,592 KB
最終ジャッジ日時 2023-10-22 04:09:29
合計ジャッジ時間 5,096 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
58,584 KB
testcase_01 AC 167 ms
58,460 KB
testcase_02 AC 180 ms
58,584 KB
testcase_03 AC 166 ms
58,576 KB
testcase_04 AC 182 ms
58,372 KB
testcase_05 AC 184 ms
58,592 KB
testcase_06 AC 182 ms
58,424 KB
testcase_07 AC 181 ms
58,420 KB
testcase_08 AC 170 ms
58,584 KB
testcase_09 AC 134 ms
57,420 KB
testcase_10 AC 168 ms
56,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	static Scanner in = new Scanner(System.in);
	static Set<String> set = new HashSet<>();
	public static void main(String[] args) {
		String s = in.next();
		f(s, "");
		System.out.println(set.size());
	}
	
	public static void f(String s1, String s2){
		if(s1.length() == 1){
			set.add(s2 + s1);
		}else{
			f(s1.substring(0, s1.length() - 1), s2 + s1.charAt(s1.length() - 1));
			f(s1.substring(1, s1.length()), s2 + s1.charAt(0));
		}
	}
}
0