Title DescriptionDescription Enter two positive integer x0,y0 (2<=x0<100000,2<=y0<=1000000) to find the number of p,q that meet the following conditions
Conditions:
1.p,a 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.
input/output format input/output
Input Format:
Two positive integers x0,y0
output Format:
A number that indicates the number of p,q that satisfy the condition
input and Output sample sample Input/output
sample Test point # #
Input Sample:3 60
Sample output:
4
idea: This problem has a small trick, because half of the answer is just the front of the upside down, so you can only enumerate to the root of the root of the x*y, and then the answer to * * (least common multiple is two number multiplied and divided by greatest common divisor
).
this problem to use to return to seek greatest common divisor, symplectic deficit data is not small (*^__^*), or can also be used to divide the method to seek greatest common divisor!
The code is as follows:
1#include <stdio.h>2#include <math.h>3 intOJLD (intIintJ//Greatest Common divisor (recursive)4 { 5 if(i==0)returnJ; 6OJLD (j%i,i); 7 } 8 intMain ()9 { Ten intx,y,q,num=0, K; One inti; Ascanf"%d%d",&x,&y); -k=x*y; -q=sqrt (k); the for(i=x;i<=q;i++) - { - if(k%i==0&&OJLD (i,k/i) ==x) num++; - } +printf"%d\n", num*2); - return 0; +}
Greatest common divisor and least common multiple issues