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(Scanner.java:862) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextInt(Scanner.java:2117) at java.util.Scanner.nextInt(Scanner.java:2076) at Codechef.main(Main.java:15)

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
1
10^5
-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
so
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.

2 Likes

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