nCr mod M | Part 2
Submissions: 415   Accuracy:

6.61%

  Difficulty: Medium   Marks: 4

Given 3 integer N,R and M. You task is to calculate NCR%M.

Input:

The first line of the input contains an integer T denoting the number of test cases.Then T test cases follow. Each test case consists of 3 integers N,R and M.


Output:

For each test case output a single integer representing the value of NCR%M

Constraints :
1<=T<=100
1<=R<=N<=10^9
1<=M<=10^5 where  M is a square free and the largest prime factor of M is <=50.

 

Example:
Input:
3
4 2 28681
3 1 43710
5 3 3655

Output:
6
3
10

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Pranay Pandey
Author: pra1nay7_313


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.