結果

問題 No.170 スワップ文字列(Easy)
ユーザー E. Gordon
提出日時 2019-04-09 22:21:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 56,692 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-05 04:30:36
合計ジャッジ時間 1,759 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int fac(int n)
{
    if(n <= 1) return 1;
    return n * fac(n-1);
}
int main()
{
    string s;
    int alp['Z'-'A'+1] = {0}, ans;
    cin >> s;
    ans = fac(s.size());
    for(int i = 0; i < (int)s.size(); i++){
        alp[s[i] - 'A'] += 1;
    }
    for(int i = 0; i < 'Z'-'A'+1; i++){
        if(alp[i] > 1) ans /= fac(alp[i]);
    }
    cout << ans - 1 << endl;
    return 0;
}
0