UVa 10338 – Mischievous Children


/*
User ID: turing_13
Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1279
*/

#include <bits/stdc++.h>

#define ll long long
#define sc scanf
#define pf printf
#define Pi 2*acos(0.0)

using namespace std;

long long func(int num)
{
    long long ans=1;
    if(num==0)
        return 1;
    ans=num*func(num-1);
    return ans;
}
int main()
{
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    long long t;
    //cout<<func(14)/24<<endl;
    cin>>t;

    getchar();
    for(int l=1; l<=t; l++)
    {
        string str;
        map <char,int>mp;
        cin>>str;
        int len=str.length();

        for(int i=0; i<len; i++)
            mp[str[i]]++;
        vector <int>v;
        for(char c='A'; c<='Z'; c++)
        {

            if(mp>1)
                v.push_back(mp);
        }
        long long ans=func(len);
        for(int i=0; i<v.size(); i++)
            ans/=func(v[i]);
        cout<<"Data set "<<l<<": "<<ans<<endl;
    }
    return 0;
}


0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments