(SPOJ) Distância de Manhattan - Solution

import java.io.*;
import java.util.*;
import java.lang.*;

class Main  { 
    public static void process() throws NumberFormatException, IOException {   
        Scanner sc = new Scanner(System.in);
       
        int mariaX = sc.nextInt();
        int mariaY = sc.nextInt();
        int meetingX = sc.nextInt();
        int meetingY = sc.nextInt();
               
        System.out.println(Math.abs(mariaX-meetingX) + Math.abs(mariaY-meetingY));
       
        return;
    }
   
    public static void main(String[] args) throws NumberFormatException, IOException {
        Main m = new Main();
        m.process();

        System.exit(0);
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução