long long int CalculatePower(int number, int power)
{
long long int product=1;
for(int i=1;i<=power;i++)
{
product*=number;
}
return product;
}
int main()
{
int testCase;
cin>>testCase;
for(int i=1;i<=testCase;i++)
{
int N;
long long int M;
int Q;
cin>>N>>M>>Q;
if(N < 2 || N > 100000)
break;
if(M < 1 || M > 1000000000)
break;
int rArray[20];
for(int k=0;k<Q;k++)
{
cin>>rArray[k];
if(rArray[k] < 1 || rArray[k] > N)
exit(0);
}
long long int sum=1;
for(int i=1;i<=N;i++)
sum *= CalculatePower(i, i);
for(int j=0;j<Q;j++)
{
long long int sum1=1;
for(int k=1;k<=rArray[j];k++)
sum1*=CalculatePower(k, k);
long long int sum2=1;
for(int k=1;k<=N-rArray[j];k++)
sum2*=CalculatePower(k, k);
long long int total = 0;
total = sum/(sum1 * sum2);
cout<<"total = "<<total<<endl;
cout<<total%M<<endl;
}
}
return 0;
}
I don’t know what is wrong with my code.
Bit new to programming, Please help.
First program I tried here and is not working.