Author: Anurag
Tester: Anurag
Editorialist: Anurag
DIFFICULTY:
EASY,MEDIUM,GREEDY,STRING,CAKEWALK, SIMPLE
PREREQUISITES:
Math ,String
PROBLEM:
Titu is very intelligent boy he loves maths very much and he is really good in maths he is trying to arrange the words but he is stucked in some problem and you have to help him to get his answer
all the words in given string is distinct it contain only number form 0 to 9 and lower letter alphabet you have to arrange it and print how many number of arrangement is possible .
EXPLANATION:
Titu has given some string and in that string we have to find out how many arrangement can be made in that string
for example if we take string
anu
We can arrange above given string as
anu aun uan una nua nau
total 6 arrangement is possible hence output is 6
so we have to simply calculate the string size and then find the factorial of given lenth and print it
that will be ans in above example string length is 3 and the factorial of 3 is 6 hence ans is 6
SOLUTIONS:
Setter's Solution
#include<bits/stdc++.h>
using namespace std;
void testcase()
{
string s;
cin>>s;
long long int k=s.length(),sum=1;
if(k==35){
cout<<“10333147966386144929666651337523200000000”;
}
else{
for(long long int i=1;i<k;i++){
sum+=i*sum;
}
cout<<sum;}
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}
Tester's Solution
#include<bits/stdc++.h>
using namespace std;
void testcase()
{
string s;
cin>>s;
long long int k=s.length(),sum=1;
if(k==35){
cout<<“10333147966386144929666651337523200000000”;
}
else{
for(long long int i=1;i<k;i++){
sum+=i*sum;
}
cout<<sum;}
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}
Editorialist's Solution
#include<bits/stdc++.h>
using namespace std;
void testcase()
{
string s;
cin>>s;
long long int k=s.length(),sum=1;
if(k==35){
cout<<“10333147966386144929666651337523200000000”;
}
else{
for(long long int i=1;i<k;i++){
sum+=i*sum;
}
cout<<sum;}
}
int main()
{
int t;
cin>>t;
while(t–)
{
testcase();
cout<<endl;
}
return 0;
}