Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
2.2 kB
2
Indexable
Never
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using db = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<db, db>;
using tiii = tuple<int, int, int>;
using str = string;

#define vt vector
#define pb push_back
#define eb emplace_back
#define ins insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

constexpr int MOD = 1e9 + 7;
vt<ll> fac(int(1e6 + 7));

int f(int n) {
    if (n == 1 || n == 0) {
        return 1;
    }
    
    else {
        return (fac[n - 1] * n) % MOD;
    }
}

ll fastpow(ll base, ll pow) {
    ll result = 1;
    while(pow > 0) {

        if(pow & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        pow >>= 1;
    }
    return result;
}

void solve() {
    string s;
    cin >> s;
    set<char> st;
    for (auto i : s) {
        st.ins(i);
    }
    
    for (int i = 0; i <= 1e6 + 7; ++i) {
        fac[i] = f(i);
    }
    
    map<char, int> d;
    
    for (int i = 0; i < (int)s.size(); ++i){
        if (d.count(s[i]) == 0){
            d[s[i]] = 1;
        }
        else {
            d[s[i]]++;
        }
    }
    
    for (auto i : d) {
        cout << i.fi << " : " << i.se << endl;
    }
    
    
    ll ch = 0, z = 1;
    
    for (auto i : st){
        ch += d[i];
        z = (z * fastpow(d[i], MOD - 2)) % MOD;
    }
    
    cout << (fac[ch] * z) % MOD << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
//     freopen("data.in", "r", stdin);
//     freopen("data.out", "w", stdout);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}