# [Number Theory] [maximum public approx.] [enumeration approx.] codevs 1012 maximum public approx. and minimum public I issues in 2001 noip National League popularity Group

Source: Internet
Author: User

For a pair of numbers (p, q), if their GCD is x0 and the LCM is y0,

P * q/X0 = y0, that is, q = x0 * Y0/P,

Since p and q are positive integers, p and q must all be x0 * y0 divisor.

Therefore, the O (SQRT (x0 * y0) enumerated approx. It is determined by GCD in sequence.

`1 # include <cstdio> 2 # include <cmath> 3 using namespace STD; 4 typedef long ll; 5 ll limit, Q, P, to; 6 int ans; 7 LL gcd (ll a, LL B) {return B = 0? A: gcd (B, A % B);} 8 int main () 9 {10 scanf ("% d", & P, & Q ); limit = p * q; 11 to = SQRT (Limit); 12 for (ll I = P; I <= to; I ++) 13 if (Limit % I = 0) 14 if (gcd (I, limit/I) = P) 15 ans ++; 16 printf ("% d \ n ", ans <1); 17 return 0; 18}`

[Number Theory] [maximum public approx.] [enumeration approx.] codevs 1012 maximum public approx. and minimum public I issues in 2001 noip National League popularity Group

Related Keywords:

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.