NOIP2001 Universal group GCD and LCM issues

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.