Title Description
Description
Enter two positive integer x0,y0 (2<=x0<100000,2<=y0<=1000000) to find the number of p,q that meet the following conditions
Condition: 1.p,q is a positive integer
2. Require p,q to x0 for greatest common divisor, y0 as least common multiple.
Trial: The number of all possible two positive integers that satisfy the condition.
Enter a description
Input Description
Two positive integers x0,y0
Output description
Output Description
The number of all possible two positive integers that satisfy the condition
Sample input
Sample Input
3 60
Sample output
Sample Output
4
Data size & Hint
3 60
60 3
12 15
15 12
Idea: y/x then decomposes factorization and then the power of 2 is the answer.
1#include <stdio.h>2#include <math.h>3 intx, y;4 BOOLZhiintx)5 {6 for(intI=2; i<=sqrt (x); + +i)7 if(x%i==0)return 0;8 return 1;9 }Ten intMain () One { Ascanf"%d%d",&x,&y); - if(y%x!=0) - { theprintf"0/n"); - return 0; - } -x=y/x; y=0; + for(intI=2; i<=x;++i) - if(Zhi (i)) + { A if(x%i==0) ++y; at while(x%i==0) x/=i; - } -printf"%d/n",(int) Pow (2, y)); - return 0; -}
View Code
(number theory) greatest common divisor and least common multiple problems