/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
string str ;
ll cnt[50] ;
ll findFactorial(ll n)
{
if(n==0)
return 1 ;
ll i ;
ll fact =1 ;
for(i=1 ; i<=n ; i++)
fact = fact*i ;
return fact ;
}
int main()
{
ll test;
ll cs =1 ;
ll i,k,t,ln1 ;
ll total,p ;
sc("%lld",&test) ;
while(test--)
{
memset(cnt,0,sizeof(cnt)) ;
cin>>str ;
ln1 = str.size() ;
p = findFactorial(ln1) ;
for(i=0 ; i<str.size() ; i++)
{
k = str[i] - 'A' ;
cnt[k]++ ;
}
total =1 ;
for(i=0 ; i<26 ; i++)
{
if(cnt[i]>0)
{
t = findFactorial(cnt[i]) ;
total*=t ;
}
}
pf("Data set %lld: %lld\n",cs++,(p/total)) ;
}
return 0;
}
/*
worst case
ABCDDAAABFFGHIJKLLML
*/
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
string str ;
ll cnt[50] ;
ll findFactorial(ll n)
{
if(n==0)
return 1 ;
ll i ;
ll fact =1 ;
for(i=1 ; i<=n ; i++)
fact = fact*i ;
return fact ;
}
int main()
{
ll test;
ll cs =1 ;
ll i,k,t,ln1 ;
ll total,p ;
sc("%lld",&test) ;
while(test--)
{
memset(cnt,0,sizeof(cnt)) ;
cin>>str ;
ln1 = str.size() ;
p = findFactorial(ln1) ;
for(i=0 ; i<str.size() ; i++)
{
k = str[i] - 'A' ;
cnt[k]++ ;
}
total =1 ;
for(i=0 ; i<26 ; i++)
{
if(cnt[i]>0)
{
t = findFactorial(cnt[i]) ;
total*=t ;
}
}
pf("Data set %lld: %lld\n",cs++,(p/total)) ;
}
return 0;
}
/*
worst case
ABCDDAAABFFGHIJKLLML
*/
No comments:
Post a Comment