No Such Element Exception in JAVA

does not have enough karma ,so asking here: why my code for NEO01(chef and feast) gives this error-- Exception in thread “main” java.util.NoSuchElementException at java.util.Scanner.throwFor( at at java.util.Scanner.nextInt( at java.util.Scanner.nextInt( at Codechef.main(

1 Like

@manoj09 in ur code, u have declared result variable as int type…it should be declared as long
lets take a sample case as
-10^8 -10^8 -10^8 … so on upto 10^5 terms in regard of 30 points…

logically our result will be correct if we make subset of individual element
1* (-10^8)+1* (-10^8)+1* (-10^8)+1* (-10^8)+1* (-10^8)+1* (-10^8)+… upto 10^5 terms

on solving we are getting -10^13 as result which is out of range of int… so declare result variable as long type and if problem persist… just ping me again

its not working yet
is there any problem of scanner class to take input in codechef editor.


I am also facing the same issue.
Is this still not fixed ?

I am also getting same error… When I run with custom input it runs perfectly but when I submit at that time I am getting error