We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
this is my code enclosed below it seems to work for all test cases yet the editor is not accepting it on account of runtime error can somebody please suggest any edits to it
include
using namespace std;
int factorial(int a)
{
if(a==0||a==1)
{
return 1;
}
else{
return a*factorial (a-1);
}
}
int main()
{
int n,m;
cin>>n>>m;
int ans=(factorial(n+m))/(factorial(m)*factorial(n));
int ans1=(factorial(m+m-1))/(factorial(n-1)*factorial(m));
int final_ans=ans-ans1;
cout<
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
this is my code enclosed below it seems to work for all test cases yet the editor is not accepting it on account of runtime error can somebody please suggest any edits to it
include
using namespace std; int factorial(int a) { if(a==0||a==1) { return 1; } else{ return a*factorial (a-1); }
} int main() { int n,m; cin>>n>>m; int ans=(factorial(n+m))/(factorial(m)*factorial(n)); int ans1=(factorial(m+m-1))/(factorial(n-1)*factorial(m)); int final_ans=ans-ans1; cout<