Noip2001-Universal Group Rematch-second question-greatest common divisor and least common multiple issues

Source: Internet
Author: User
Tags greatest common divisor

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 skill, because half of the answer is just the front of the upside down, so you can only enumerate to the root of the square x*y, and then the answer. this question to use to return to beg greatest common divisor, Xin loss data is not big, otherwise will "boom", haha, joking ^_^. 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&AMP;&AMP;OJLD (i,k/i) ==x) num++;  -     }    +printf"%d\n", num*2);  -     return 0;  +}

Noip2001-Universal Group Rematch-second question-greatest common divisor and least common multiple issues

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.