結果
| 問題 | No.170 スワップ文字列(Easy) | 
| コンテスト | |
| ユーザー |  h_noson | 
| 提出日時 | 2016-03-13 12:15:23 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 714 bytes | 
| コンパイル時間 | 667 ms | 
| コンパイル使用メモリ | 73,368 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-23 00:36:15 | 
| 合計ジャッジ時間 | 1,503 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8
typedef long long ll;
int combination(int n, int r) {
    if (n == r || r == 0)
        return 1;
    else
        return combination(n-1,r) + combination(n-1,r-1);
}
int main() {
    int n, ans;
    string s;
    map<char,int> m;
    cin >> s;
    for (auto c : s)
        m[c]++;
    n = s.size();
    ans = 1;
    for (auto p : m) {
        ans *= combination(n,p.second);
        n -= p.second;
    }
    cout << ans - 1 << endl;
    return 0;
}
            
            
            
        