ValeryisaPEteacherataschoolinBerland.Soonthestudentsaregoingtotakeatestinlongjumps,andValeryhaslosthisfavoriteruler!However,thereisnoreasonfordisappointment,asValeryhasfoundanotherruler,itslengthislcentimeters.Theruleralreadyhasnmarks,withwhichhecanmakemeasurements.Weassumethatthemarksarenumberedfrom1tonintheordertheyappearfromthebeginningoftherulertoitsend.Thefirstpointcoincideswiththe...
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...
近期评论