#define LL long long
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define REV(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define pri(a) cout<<a<<endl
#define priii(a,b,c) cout<<a<<" "<<b<< " " <<c << endl
#define hi printf("Hello World\n");
using namespace std;
const int INF = 1<<29;
const int MX = 1e5+10;
/// how many ways can the chars of a string be rearranged including its own arrangement??
/// total str size's factorial / (product of all repetitive chars' individual factorial)
LL fact[25];
void f()
{
fact[0]=1;
FOR(i,1,22)
{
fact[i]=fact[i-1]*i;
}
}
int main()
{
f();
int T,cs=0;
string s;
cin>>T;
while(T--)
{
cin>>s;
int a[26]={0}; ///*
REP(i,SZ(s))
{
a[ s[i]-'A']++;
}
LL ways = fact[SZ(s)];
REP(i,26) ways /= fact[a[i]];
printf("Data set %d: ", ++cs);
pri(ways);
}
return 0;
}
No comments:
Post a Comment