provide link to the question also
Can anyone check why am I getting NZEC in java… I have done everything possible after searching this whole Forum…
https://www.codechef.com/viewsolution/13196898
I am getting NZEC error pleaSE help me .
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
int c=calculate();
System.out.println(c);
}
public static int calculate()
{
int count=0;
Scanner inp=new Scanner(System.in);
System.out.println("Enter No. of time input take:\t ");
int n=inp.nextByte();
int a[]=new int[n];
System.out.println("All input must be divisible \t "); //k<10pow7
int k=inp.nextByte();
System.out.println("Enter values:");
for(int i=0;i<n;i++) {
a[i] = inp.nextInt();
if (a[i] % k == 0)
count++;
}
return count;
}
}
I was solving this problem SUMTRIAN( https://www.codechef.com/problems/SUMTRIAN ) and was getting this error with Python. I was getting input using raw_input() which was coupled with split(’ ') to get a list. This is how I was taking input and converting it into a list of integers : lst = map(int, list(raw_input().split(’ ')))
Solution to this error:
Change the code to : lst = map(int, list(raw_input().strip().split(’ ')))
strip() removes any unnecessary blank spaces in the input and this removed the NZEC error.
guys, please upvote me. i am new here. nad not able to ask question
you should probably return a 0 value
by taking int main() as the function in c
For the python users, you can refer to this discussion http://stackoverflow.com/questions/9444503/nzec-error-in-python…
Hope it helps…!
For python use the following link.
https://www.quora.com/How-do-I-take-input-from-STDIN-in-Python/answer/Pratiush-Prasunn
Some python specific debugging NZEC:
If the issue is due to leading or trailing spaces any of the below should work for Python:-
- input().strip().split()
- input().strip().split(’ ')
- raw_input().strip().split()
- raw_input().strip().split(’ ')
If not there might be some other issue -
Common exceptions are
- LookupError (IndexError, KeyError)
- ArithmeticError (FloatingPointError, OverflowError, ZeroDivisionError)
The last thread is not python specific but the idea is great. I faced the issue currently in python so added these for common good.
I was getting same for a question in Python 2, try switching to input() and submit in Python 3. It worked for me.
My code is executing fine on my laptop but give NZEC error on codechef .Please can anyone tell me what’s wrong with it.
import java.util.Scanner;
public class Main {
static int max, p;
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
long n = inp.nextInt();
int A[] = new int[1000];
int B[] = new int[1000];
int i, j;
int lead;
for (i = 0; i < n; i++) {
A[i] = inp.nextInt();
B[i] = inp.nextInt();
}
for (i = 0; i < n; i++) {
if (A[i] > B[i]) {
lead = A[i] - B[i];
if (lead > max) {
max= lead;
p = 1;
}
}
else {
lead = B[i] - A[i];
if (lead > max) {
max = lead;
p = 2;
}
}
}
System.out.println(p+ " " + max);
}
}
my code is running fine in my laptop but getting nzec in codechef . iam using java and i have used bufferedreader class and scanner class both but iam still getting nzec in both cases
@codehardy can you please mention for which question you have write this code as you have created array A and B of size 1000 elements , which may be insufficient according to the constraints of the question.
Hello please, I am struggling with it too
package bytelandian;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
class Bytelandian {
Map<Long, Long> alreadyComputed = new HashMap<>();
Long compute(Long n) {
if (n < 12) {
return n;
}
if (alreadyComputed.containsKey(n)) {
return alreadyComputed.get(n);
}
Long tmp = compute(n / 2) + compute(n / 3) + compute(n / 4);
if (tmp < n) {
tmp = n;
}
alreadyComputed.put(n, tmp);
// System.out.println(alreadyComputed + "");
return tmp;
}
public static void main(String[] args) throws Exception {
Bytelandian b1 = new Bytelandian();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while (!(line = br.readLine()).equals("")) {
System.out.println(b1.compute(Long.parseLong(line)));
}
}
}
example submission:
https://www.codechef.com/viewsolution/17182239
it says 4468M mem, but it seems impossible to me
please help, I would like to complete challenges, but error after error occurs when I would like to check my work
It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try
It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try
It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try
It might be because you have referred to out of bound index array (that ie, referring to index > len(array). I also got this error on first try