KPRIME - Simple code in java throwing NZEC. pls help me figure out why


import java.util.StringTokenizer;

public class Main {

	 * @param args
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		int [] markedCount = new int[100001];
		for(int i = 2; i <= 100000; i++) {
			if(markedCount[i] == 0) {
				for(int j = i; j <= 100000; j += i) {
					markedCount[j] += 1;
		BufferedReader br = new BufferedReader(new InputStreamReader(;
		StringBuilder result = new StringBuilder();
		int T = Integer.parseInt(br.readLine());
		int A, B, K;
		StringTokenizer sz;
		while(T-- > 0) {
			sz = new StringTokenizer(br.readLine(), " ");
			A = Integer.parseInt(sz.nextToken());
			B = Integer.parseInt(sz.nextToken());
			K = Integer.parseInt(sz.nextToken());
			int resultN = 0;
			for(int i = A; i <= B; i++) {
				if(markedCount[i] == K) {



Can some one help me figure where the exception is thrown? I tried but din’t get a clue :frowning:

@prav90 : Maybe this is related to :

Code Chef was upgrading java compiler so all submissions were having Runtime error

However that is resolved now .

If you continue to have this problem of Runtime Error , then mention it that it is not related to compiler upgrade and i will have a look at your code .

Please update if you are still getting Runtime Exception .

@vineetpaliwal : I’m still getting NZEC. This is the solution i submitted

@vineetpaliwal: I got an AC with this solution I think codechef is reporting NZEC for TLE, because my previous solution was naive, and I wasn’t able to find a place where exceptions could be thrown in my previous submissions.

@prav90 : Yes could not find a source of exception in your earlier solution also . Need to report this to or as the ERROR CODE returned should be correct . Will investigate this a bit more and if i feel TLE is showing as RE then I will write to admins . Meanwhile if you are sure you may write to CodeChef.