UVA – 10055 – Hashmat the brave warrior

  • ID : UVA – 10055 – Hashmat the brave warrior
  • Submissions :
    • Java – Accepted
  • Difficulty : Shame to Solve
  • Type : Adhoc
  • Time for Submission : 10 minutes
  • Solution Description :
    • Output the Absolute difference between the two numbers
  • Problems :
    • The problem statement declares that the input won’t exceed (2^31) , while int limit is (2^31-1) so use long instead


import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Long> sol = new ArrayList<Long>();
		while(in.hasNext()){
			long v=in.nextLong(),t=in.nextLong();
			sol.add(Math.abs(t-v));
		}
		for(long s : sol)
			System.out.println(s);
	}
}
Advertisements

One thought on “UVA – 10055 – Hashmat the brave warrior

  1. Shipu Ahamed says:

    hmm……..nice & thnx…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: