
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-69272a325f5f7793943335/]output[crayon-69...
近期评论