結果
問題 | No.170 スワップ文字列(Easy) |
ユーザー |
![]() |
提出日時 | 2017-10-01 23:45:45 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 125 ms / 5,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 3,518 ms |
コンパイル使用メモリ | 78,028 KB |
実行使用メモリ | 54,268 KB |
最終ジャッジ日時 | 2024-11-15 21:50:41 |
合計ジャッジ時間 | 8,014 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
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); } }