Java | Getting NZEC in Flow004 even though it is working fine on local machine

Hi,
I am getting NZEC in the problem Flow004. I am using Java and this is my code. I searched for this and found some answers but I still couldn’t resolve it. When I tried it using some custom inputs too, it worked fine. Could someone please help?

My approach:

  1. For last digit sum = num % 10
  2. for first digit:
    loop → i = 1 - 6
    if num <= 9 break;
    //first and last digits will be same for single digit numbers
    else if (num / 10 ^ i <= 9) sum = sum + num / 10 ^ 9 break;
    //dividing num by (10, 100, 1000,…,1000000) if quotient is <=9 then it is first digit
    Thanks

for some reason CodeChef gives some really weird NZEC errors in JAVA and sometimes EOF in Python… the custom input always works fine and on using the same logic in C++ the code works fine so ig when it comes to CodeChef especially short contests doing C++ is much wise

1 Like

Hi, I would be glad if you could please take a look at my code, just to see whether this NZEC is being caused due to the platform and not my code?