long long int CalculatePower(int number, int power)
long long int product=1;
for(int i=1;i<=power;i++)
return product;

int main()

int testCase; 
for(int i=1;i<=testCase;i++)
    int N;
    long long int M;
    int Q;
    if(N < 2 || N > 100000)
    if(M < 1 || M > 1000000000)

    int rArray[20];
    for(int k=0;k<Q;k++)
        if(rArray[k] < 1 || rArray[k] > N)
    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;  

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.

Do not print “total=” at least, print out only what you are asked for to be printed, nothing more…

Submission link is preferred - , your goal is 9 points, right? If not this problem is not so easy… I’d recommend you to start with something easier :wink:

Editorial is available at -

thank you betista … It worked.
I have one question…if we want to increase the size of the int more than “long long int” i.e more than 8 byte.
Is there any data type in C++ more than 8 byte.
Or we have to use character array and perform the large calculation writing own operation.
If yes then does it not slow down the running time.

Thanks in advance.

It does (slow the execution). But you are asked to print the result as modulo M, so the result is always int. As I said this is not so easy problem only ~300 contestats had 100 point out of 2500…