For the Factor M in this question, you only need to convert it into the product form of the prime factor. Then, you only need to determine whether the number of each prime factor P in the combination is greater than or equal to the number in the factor M, if yes, the output is yes. If one is not, the output is no. How to determine the number of prime factors in the number of combinations is as follows:
// Obtain the number of prime factor p in 1*2 * · N
Int getnum (int n, int p ){
Int res;
Res = 0;
While (n ){
Res + = N/P;
N/= P;
}
Return res;
}
The Code is as follows:
# Include <stdio. h>
# Include <string. h>
# Include <math. h>
# Define Nmax 46345
Int flag [Nmax], prime [Nmax], pfactor [Nmax], cpfactor [Nmax];
Int Plen, cplen;
// Input the prime number table
Void mkprime (){
Int I, J;
Memset (flag,-1, sizeof (FLAG ));
For (I = 2, Plen = 0; I <Nmax; I ++ ){
If (flag [I]) {
Prime [Plen ++] = I;
}
For (j = 0; (j <Plen) & (I * prime [J] <Nmax); j ++ ){
Flag [I * prime [J] = 0;
If (I % prime [J] = 0 ){
Break;
}
}
}
}
// Convert K into the form of the product of the prime factor
Void findpfactor (int K ){
Int I, Te, CNT;
Te = (INT) SQRT (K * 1.0 );
For (I = 0, cplen = 0; (I <Plen) & (prime [I] <= tE); I ++ ){
If (K % prime [I] = 0 ){
CNT = 0;
While (K % prime [I] = 0 ){
CNT ++;
K/= prime [I];
}
Pfactor [cplen] = prime [I];
Cpfactor [cplen ++] = CNT;
}
}
If (k> 1 ){
Pfactor [cplen] = K;
Cpfactor [cplen ++] = 1;
}
}
// Obtain the number of prime factor p in 1*2 * · N
Int getnum (int n, int p ){
Int res;
Res = 0;
While (n ){
Res + = N/P;
N/= P;
}
Return res;
}
Void solve (int n, int m ){
Int I, temp;
For (I = 0; I <cplen; I ++ ){
Temp = getnum (n, pfactor [I])-getnum (M, pfactor [I])
-Getnum (n-M, pfactor [I]);
If (temp <cpfactor [I]) {
Puts ("no ");
Return;
}
}
Puts ("yes ");
}
Int main (){
# Ifndef online_judge
Freopen ("data. In", "r", stdin );
# Endif
Int t, n, m, K;
Mkprime ();
Scanf ("% d", & T );
While (t --){
Scanf ("% d", & N, & M, & K );
Findpfactor (k );
Solve (n, m );
}
Return 0;
}