Page 12 of 12

Re: 10055 - Hashmat the Brave Warrior

Posted: Mon Dec 22, 2014 7:00 am
by Dimpl
Is there any reason that UVa would have an issue with Math.abs? My solution was not accepted until I replaced:

System.out.println(Math.abs(a - b));

with

if (a > b)
System.out.println(b - a);
else
System.out.println(a - b);

Re: 10055 - Hashmat the Brave Warrior

Posted: Tue Dec 23, 2014 10:23 am
by lighted
I think you mean

Code: Select all

if (a > b)
    System.out.println(a - b);
else
    System.out.println(b - a);
The input numbers are not greater than 2^32
What type did you use for input numbers, int or long? Check code http://ideone.com/ToCMGb