Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Dementia Problem MULFACT

$
0
0

What is wrong with my solution. I can't figure out what was wrong.

/*  ashish1610  */
#include<bits/stdc++.h>
using namespace std;
#define mod 329885391853
/*  fast input  */
inline void inp(long long int &n) 
{
      n=0;
  register long long int ch=getchar_unlocked();
  long long int sign=1;
      while(ch<'0'||ch>'9')
  {
    if(ch=='-')
        sign=-1; 
    ch=getchar_unlocked();
}
    while(ch>='0'&&ch<='9')
        n=(n<<3)+(n<<1)+ch-'0',ch=getchar_unlocked();
    n=n*sign;
  }
  int main() 
 {
int t;
cin>>t;
while(t--)
{
    long long int n;
    inp(n);
    if(n>=999983)
    {
        cout<<0<<endl;
    }
    else
    {
        long long int ans=1,fact=1;
        for(long long int i=1;i<=n;++i)
        {
            fact=((fact%mod)*(i%mod))%mod;
            ans=((ans%mod)*(fact%mod))%mod;
        }
        cout<<ans%mod<<endl;
    }
}
return 0;

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles