Devuandhisbrotherloveeachotheralot.Astheyaresupergeeks,theyonlyliketoplaywitharrays.Theyaregiventwoarrays a and b bytheirfather.Thearray a isgiventoDevuand b tohisbrother.AsDevuisreallyanaughtykid,hewantstheminimumvalueofhisarray a shouldbeatleastasmuchasthemaximumvalueofhisbrother'sarray b.NowyouhavetohelpDevuinachievingthiscondition.Youcanperformmultipleoperationsonthearrays...
Prof.Vasechkinwantstorepresentpositiveinteger n asasumofaddends,whereeachaddendsisanintegernumbercontainingonly1s.Forexample,hecanrepresent121as121=111+11+–1.Helphimtofindtheleastnumberofdigits 1 insuchsum.InputThefirstlineoftheinputcontainsinteger n (1 ≤ n < 1015).OutputPrintexpectedminimalnumberofdigits 1.Sampletest(s)input[crayon-6743da6a4614c739423644/]output[crayon-67...
近期评论