2045: Number of parents

Source: Internet
Author: User
Tags greatest common divisor

2045: Parents time limit:10 Sec Memory limit:259 MB
submit:659 solved:302
[Submit] [Status] [Discuss] Description Small D is a math enthusiast who is fascinated by numbers to the point of madness. We use D = gcd (A, B) to denote the greatest common divisor of a, B, and small d that this intimate relationship can be described by both parents, at which point we call the number of pairs (a, b) of the parents of D. Unlike normal parents, he has too many parents for the same d. >_< for example, (4, 6), (6, 4), (2, 100) are both parents of 2. So the question is, for 0 < a <= A, 0 < b <= B, how many ordered pairs (A, b) are the parents of d? Input inputs have only one row, three positive integers a, B, D (d <= A, b), meaning title. The output outputs an integer line that gives the number of parents that satisfy the condition. Sample Input





5 5 2
Sample Output3


"Sample Interpretation"

Three pairs of parents satisfying the conditions (2, 2) (2, 4) (4, 2)
HINT

For 100% of data meet 0 < A, B < 10^ 6

Source

The first "Noier" national competition

BZOJ2301: Basically with the same, is greatly weakened = =

1/**************************************************************2Problem:20453 User:hansbug4 language:pascal5 result:accepted6Time:1448Ms7Memory:11944KB8****************************************************************/9  Ten Constmaxn=1500000; One var A I,j,k,l,m,n,x1,y1,x2,y2,z:longint; -B:Array[0.. MAXN] ofLongint; - procedureSwapvarx,y:longint); the           varZ:longint; -           begin -z:=x;x:=y;y:=Z; -           End; + functiondoit (x,y:longint): Int64; -          varI,j,k:longint; +          begin Adoit:=0; at               ifX>y Thenswap (x, y); -               ifx=0  ThenExit0); -i:=1; -                whileI<=x Do -                     begin -                          if(xDiv(xDivi)) < (yDiv(YDivi)) Then inK:=xDiv(xDivi) -                          ElseK:=yDiv(YDivi); toInc (doit, (b[k]-b[i-1]) *int64 (xDivi) *int64 (yDivi)); +i:=k+1; -                     End; the          End; * begin $       fori:=2  toMaxn DoPanax Notoginseng          begin -               ifA[i]<>0  Thencontinue; the                forJ:=i toMaxnDivI Doa[i*j]:=i; +          End; Ab[1]:=1; the       fori:=2  toMaxn Do +          ifa[i]=0  Thenb[i]:=-1 Else -             if((iDivA[i])MoDA[i]) =0  Thenb[i]:=0 Else $B[i]:=-b[iDivA[i]]; $       fori:=2  toMaxn Dob[i]:=b[i]+b[i-1]; - readln (n,m,l); -Writeln (doit (nDivL,mDivl)); the Readln; - End.

2045: Number of parents

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.