DivModulo
Time limit3sMemory limit1024 MB
Compute C(M,N) after removing every factor of D, and report the remainder modulo D, for M up to 4e18 and D up to 1.6e7.
- Level
Hard9 of 10
- Topics
- Math, Number theory, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
Modulo (mod) is a very common operator on integers. For two integers and with , is defined as the value such that and there exists an integer with . For example, means the remainder of 200 divided by 5 is 0.
Here is another new operator called DivModulo (dmod) defined as follows. For two integers and with , is defined as the value such that where there exist integers and with and is not a factor of . For example, , since and .
Consider the factorials and the combination function. For an integer , the factorial is defined as , and is defined. For integers and with , the combination function is defined as . Now given three integers , , with , compute . For example, .
Input
Three integers , , and are given in one line.
Output
Print in one line.