NTH1 - Nobabs Treasure Hunt
All of us love treasures, right? That's why young nobab Ashraf-uddowla searching for a Treasure Island. And one day he find a 2d grid Treasure Island, but here is one problem. The problem is that if any one wants to find the Treasure, at first he/she solve a riddle. The riddle is “To get something, you have to give something”. Nobab Ashraf-uddowla know well that only one person can solve this riddle and he is shah-sufi-Apple-Mahmud. That’s what he think sufi-apple solved this riddle and said that if any one wants to find that Treasure for each move he/she will spend 1 taka. That mean if you are in place (x,y) in the grid you will pay 1 taka for (x,y+1) or (x,y-1) or (x+1,y) or (x-1,y) each move. Thats not enough, sufi-apple also said that only that person can open the treasure who spend least taka for finding Treasure. Now nobab very worried about Treasure and decide that who can help him to find that Treasure will awarded by one AC(accepted).
You have a good chance of being rewarded. So help nobab to finding Treasure .
First line contains four positive integers (x,y) and (t1,t2) where (x,y) is the position of you in 2d grid and (t1,t2) is the position of Treasure .
note that diagonal moves are not possible .
- -1000000 ≤ (x,y) ≤ 1000000
- -1000000 ≤ (t1,t2) ≤ 1000000
Print the only integer which is the minimum cost to find Treasure.
Input: 0 0 2 0 Output: 2
This should be moved to tutorial.
Move to tutorial pleaseLast edit: 2020-03-17 22:20:24