- 1

Please solve this question

This year Chef is participating in a Dancing competition. The dance performance will be done on a linear stage marked with integral positions. Initially, Chef is present at position XX and Chef's dance partner is at position YY. Chef can perform two kinds of dance moves. If Chef is currently at position kk, Chef can: Moonwalk to position k+2k+2, orSlide to position k−1k−1 Chef wants to find the minimum number of moves required to reach his partner. Can you help him find this number? Input Format First line will contain a single integer TT, the number of testcases. Then the description of TT testcases follows.Each testcase contains a single line with two space-separated integers X,YX,Y, representing the initial positions of Chef and his dance partner, respectively. Output Format For each testcase, print in a separate line, a single integer, the minimum number of moves required by Chef to reach his dance partner. Constraints 1≀T≀1031≀T≀103−103≀X,Y≀103−103≀X,Y≀103 Sample Input 1  4 3 8 -11 -5 57 492 -

21st Oct 2021, 4:06 PM
Ankit Kumar
Ankit Kumar - avatar
3 Answers