GCD and LCM Issues
http://218.5.5.242:9018/JudgeOnline/problem.php?id=1111
Time limit: 1 Sec
Memory Limit: 128 MB
Topic description
Enter two positive integer x0,y0 (2<=x0<100000,2<=y0<=1000000) to find the number of p,q that meet the following criteria.
Conditions:
1, P,q is a positive integer
2, request p,q to x0 as GCD, to y0 for LCM.
Trial: The number of all possible two positive integers that satisfy the condition.
Examples
Input: X0=3 yo=60
Output: 4
Description (without output) P Q at this time is:
3 60
15 12
12 15
60 3
So: the number of all possible two positive integers that satisfy the condition is 4 species.
Input
Enter only one row, two positive integers x0 and y0.
Output
The output has only one row, the number of all possible two positive integers that satisfy the condition.
Sample input
3 60
Sample output
4
Source
NOIP2001 Universal Group
This topic is simpler than UVA 10892 (click on the open question).
Complete code:
/*0ms,964kb*/
#include <cstdio>
int main ()
{
Long long m, N, nn, ans, I, count;
scanf ("%lld%lld", &m, &n);
if (n% m) Putchar (' 0 ')///attention to the special
else
{
n/= m;
ans = 1;
for (i = 2; I * I <= n; i = 2)///do not ask for primes because the range is small (note that n is decreasing)
{
if (n% i = = 0)
{
count = 0;
while (n% i = = 0)
{
n/= i;
++count;
}
Ans <<= 1;
}
if (i = = 2)
--i;///tips
}
if (n > 1) ans <<= 1;
printf ("%lld", ans);
}
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/