結果

問題 No.170 スワップ文字列(Easy)
ユーザー fjafjafjafjafjafja
提出日時 2017-10-01 23:45:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 3,077 ms
コンパイル使用メモリ 77,960 KB
実行使用メモリ 54,172 KB
最終ジャッジ日時 2024-04-27 17:38:28
合計ジャッジ時間 6,644 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
53,892 KB
testcase_01 AC 114 ms
53,644 KB
testcase_02 AC 97 ms
52,340 KB
testcase_03 AC 107 ms
54,112 KB
testcase_04 AC 111 ms
53,576 KB
testcase_05 AC 104 ms
53,644 KB
testcase_06 AC 96 ms
52,596 KB
testcase_07 AC 110 ms
54,028 KB
testcase_08 AC 110 ms
53,796 KB
testcase_09 AC 106 ms
53,752 KB
testcase_10 AC 97 ms
54,172 KB
testcase_11 AC 106 ms
53,564 KB
testcase_12 AC 99 ms
52,508 KB
testcase_13 AC 110 ms
53,968 KB
testcase_14 AC 109 ms
53,940 KB
testcase_15 AC 99 ms
52,432 KB
testcase_16 AC 94 ms
52,012 KB
testcase_17 AC 109 ms
53,788 KB
testcase_18 AC 114 ms
53,628 KB
testcase_19 AC 99 ms
52,500 KB
testcase_20 AC 108 ms
53,996 KB
testcase_21 AC 99 ms
52,744 KB
testcase_22 AC 104 ms
53,456 KB
testcase_23 AC 107 ms
53,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N170 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int[] cnt=new int[s.length()];
		for(int i=0;i<s.length();i++){
			if(cnt[i]==-1){
				continue;
			}
			String buf=s.substring(i,i+1);
			cnt[i]=1;
			for(int j=i+1;j<s.length();j++){
				if(buf.equals(s.substring(j,j+1))){
					cnt[i]++;
					cnt[j]=-1;
				}
			}
		}
		int ans=1;
		for(int i=s.length();i>0;i--){
			ans*=i;
		}
		for(int i=0;i<s.length();i++){
			if(cnt[i]>=2){
				for(int j=cnt[i];j>0;j--){
					ans/=j;
				}
			}
		}
		System.out.println(ans-1);
	}

}
0