Serejahaspainted n distinctpointsontheplane.Thecoordinatesofeachpointareintegers.Nowheiswondering:howmanysquaresaretherewithsidesparalleltothecoordinateaxesandwithpointspaintedinallitsfourvertexes?Helphim,calculatethisnumber.InputThefirstlinecontainsinteger n (1 ≤ n ≤ 105).Eachofthenext n linescontainstwointegers xi, yi (0 ≤ xi, yi ≤ 105),theintegersrepresentthecoordin...
Asusual,Serejahasarray a,itselementsareintegers: a[1], a[2], ..., a[n].Let'sintroducenotation:Aswapoperationisthefollowingsequenceofactions:choosetwoindexes i, j (i ≠ j);performassignments tmp = a[i], a[i] = a[j], a[j] = tmp.Whatmaximumvalueoffunction m(a) canSerejagetifheisallowedtoperformatmost k swapoperations?InputThefirstlinecontainstwointegers n and k (1 ...
PeopleintheTomskayaregionlikemagicformulasverymuch.Youcanseesomeofthembelow.Imagineyouaregivenasequenceofpositiveintegernumbers p1, p2,..., pn.Letswritedownsomemagicformulas:Here,"mod"meanstheoperationoftakingtheresidueafterdividing.Theexpression meansapplyingthebitwise xor (excluding"OR")operationtointegers x and y.Thegivenoperationexistsinallmodernprogramminglanguages.Forex...
近期评论