[Solved] UVa 562 runtime error. What can I do? [closed]

[ad_1]

I have solved it.

The problem was NoSuchElementException for the line:
n=scanner.nextInt();
I have fixed it using:

if(scanner.hasNextInt()) 
{
   n = scanner.nextInt();
}

The code has been accepted by uHunt.

[ad_2]

solved UVa 562 runtime error. What can I do? [closed]