PrincessTwilightwenttoCelestiaandLuna'soldcastletoresearchthechestfromtheElementsofHarmony.Asequenceofpositiveintegers bi isharmonyifandonlyifforeverytwoelementsofthesequencetheirgreatestcommondivisorequals1.Accordingtoanancientbook,thekeyofthechestisaharmonysequence bi whichminimizesthefollowingexpression:Youaregivensequence ai,helpPrincessTwilighttofindthekey.InputThefirstlinec...
DescriptionAlas!AsetofD(1<=D<=15)diseases(numbered1..D)isrunningthroughthefarm.FarmerJohnwouldliketomilkasmanyofhisN(1<=N<=1,000)cowsaspossible.IfthemilkedcowscarrymorethanK(1<=K<=D)differentdiseasesamongthem,thenthemilkwillbetoocontaminatedandwillhavetobediscardedinitsentirety.PleasehelpdeterminethelargestnumberofcowsFJcanmilkwithouthavingtodiscardthemilk.Input...
AboynamedGenareallywantstogettothe"RussianCodeCup"finals,oratleastgetat-shirt.Buttheofferedproblemsaretoocomplex,sohemadeanarrangementwithhis n friendsthattheywillsolvetheproblemsforhim.Theparticipantsareoffered m problemsonthecontest.Foreachfriend,Genaknowswhatproblemshecansolve.ButGena'sfriendswon'tagreetohelpGenafornothing:the i-thfriendasksGena xi rublesforhishelp insolvin...
近期评论