Givenasequenceofintegersa1, ..., anandqqueriesx1, ..., xqonit.Foreachqueryxiyouhavetocountthenumberofpairs(l, r)suchthat1 ≤ l ≤ r ≤ nandgcd(al, al + 1, ..., ar) = xi.isagreatestcommondivisorofv1, v2, ..., vn,thatisequaltoalargestpositiveintegerthatdividesallvi.InputThefirstlineoftheinputcontainsintegern,(1 ≤ n ≤ 105),denotingthelengthofthesequence.Thenextlinecont...
ThefinalroundofBayanProgrammingContestwillbeheldinTehran,andtheparticipantswillbecarriedaroundwithayellowbus.Thebushas34passengerseats:4seatsinthelastrowand3seatsinremainingrows.Theeventcoordinatorhasalistofkparticipantswhoshouldbepickedupattheairport.Whenaparticipantgetsonthebus,hewillsitinthelastrowwithanemptyseat.Ifthereismorethanoneemptyseatinthatrow,hewilltaketheleftmostone.Inordert...
DescriptionPrinceRemmargutssolvedtheCHESSpuzzlesuccessfully.Asanaward,UyuwplannedtoholdaconcertinahugepiazzanamedafteritsgreatdesignerIhsnayish.ThepiazzainUDF-UnitedDeltaofFreedom’sdowntownwasasquareof[0,10000]*[0,10000].Somebasketchairshadbeenstandingthereforyears,butinaterriblemess.Lookatthefollowinggraph.Inthiscasewehavethreechairs,andtheaudiencesfacethedirectionaswhatarro...
近期评论