提示: 欢迎访问OurACM平台。
Problem 1564 Combination

Accept: 153    Submit: 422
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

We use C(n, m) to denote the number of combinations of n things taken m at a time. We know that:

  • C(n, m) = C(n-1, m-1) + C(n-1, m)
  • C(n, m) = n! / ((n-m)!*m!)

  • The question here is very simple: given 3 integers n, m and k, can k divide C(n, m) exactly?

    Input

    The first line is number of test cases.
    For each test case, there is one line containing 3 integers – n, m (0<=m<=n<231) and k.

    Input

    The first line is number of test cases.
    For each test case, there is one line containing 3 integers – n, m (0<=m<=n<231) and k.

    Output

    For each test case, if k divides C(n, m) exactly, output “Yes”, otherwise output “No”.

    Sample Input

    4 100 48 4 100 48 8 100 48 27 100 48 81

    Sample Output

    Yes No Yes No

    Source

    FOJ月赛-2008年2月

    Submit  Back  Status  Discuss