2 shunfurh shunfurh 于 2017.11.14 23:30 提问

What is N?

Problem Description
  (This problem is really old&easy and any acmer who is good at math may solve it in second)
  As we know, math is both intangible and specific. Today you are going to solve the following math problem:
  Given one non-negative integer b, one positive number P and one positive integer M, how many n could you find to satisfy the following 2 rules?

  Here n! means n factorial , 0!=1,1!=1,2!=2,3!=6…,n!=(n-1)!*n

In the first line of the input , we have one integer T indicating the number of test cases. (1 <= T <= 20)
Then T cases follows.
For every case, only 3 integers (b, P and M) in a single line. ( 0<=b<P, 1<=P<=10^5, 1 <= M <=2^64 – 1 )

  For each test case, first you should print "Case #x: " in a line, where x stands for the case number started with 1. Then one integer indicates the number of "n" that you can find.

Sample Input
1 2 3
2 3 4
3 4 5

Sample Output
Case #1: 2
Case #2: 0
Case #3: 0

Csdn user default icon