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[c]>1)
                v.push_back(mp[c]);
        }
        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;
}


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s