I will try to make an excellent tutorial (easy to get the idea) for every A,B division 2 problem i solve ; that is the best way to help others as a Div2 guy.
540A - Кодовый замок The idea of the problem is simple enough to notice that to go from '2' to '8' there's only two possible solution(directions) : 1- 2-3-4-5-6-7-8 (forward) ---> abs(s1[i] — s2[i]) 2- 2-1-0-9-8 (backward) ---> 10 — abs(s1[i] — s2[i]) (same as : s1[i] — '0' + '9 — s2[i])
" Draw These two possible directions on a paper, to get the idea"
Then , take the minimum between the two and add them to your result counter. of course anything unclear or wrong , please ask me to handle it ASAP. Thanks :) .




