DescriptionTheFareySequenceFnforanyintegernwithn>=2isthesetofirreduciblerationalnumbersa/bwith0<a<b<=nandgcd(a,b)=1arrangedinincreasingorder.ThefirstfewareF2={1/2}F3={1/3,1/2,2/3}F4={1/4,1/3,1/2,2/3,3/4}F5={1/5,1/4,1/3,2/5,1/2,3/5,2/3,3/4,4/5}YoutaskistocalculatethenumberoftermsintheFareysequenceFn.InputThereareseveraltestcases.Eachtestcasehasonlyoneline,whichcontainsap...
Youhaveanarray a[1], a[2], ..., a[n],containingdistinctintegersfrom 1 to n.Yourtaskistosortthisarrayinincreasingorderwiththefollowingoperation(youmayneedtoapplyitmultipletimes):choosetwoindexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) isaprimenumber);swaptheelementsonpositions i and j;inotherwords,youareallowedtoapplythefollowingsequenceofassignments: tmp = a[i], a...
Mashmokh'sboss,Bimokh,didn'tlikeMashmokh.Sohefiredhim.MashmokhdecidedtogotouniversityandparticipateinACMinsteadoffindinganewjob.HewantstobecomeamemberofBamokh'steam.Inordertojoinhewasgivensomeprogrammingtasksandoneweektosolvethem.Mashmokhisnotaveryexperiencedprogrammer.Actuallyheisnotaprogrammeratall.Sohewasn'tabletosolvethem.That'swhyheaskedyoutohelphimwiththesetasks.Oneofthesetas...
It'sholiday.Mashmokhandhisboss,Bimokh,areplayingagameinventedbyMashmokh.InthisgameMashmokhwritessequenceof n distinctintegersontheboard.ThenBimokhmakesseveral(possiblyzero)moves.Onthefirstmoveheremovesthefirstandthesecondintegerfromfromtheboard,onthesecondmoveheremovesthefirstandthesecondintegeroftheremainingsequencefromtheboard,andsoon.Bimokhstopswhentheboardcontainslessthantwonumbers...
DescriptionIn1742,ChristianGoldbach,aGermanamateurmathematician,sentalettertoLeonhardEulerinwhichhemadethefollowingconjecture:Everyevennumbergreaterthan4canbewrittenasthesumoftwooddprimenumbers.Forexample:8=3+5.Both3and5areoddprimenumbers.20=3+17=7+13.42=5+37=11+31=13+29=19+23.Todayitisstillunprovenwhethertheconjectureisright.(Ohwait,Ihavetheproofofcourse,butitistoolongtowriteitonthem...
近期评论