CHEFHACK compiler

I don’t know why is happen in my computer answer is 1.ok check this one again wrong answer id 1724250.which compiler must I use when I submit my program because I use visual studio 2012 and there is no any mistake like you said -0.I check on the but in this site I get always wrong answer .for example in my computer give answer 20 which test case is:
2 6 4
4 8 9
7 9 4
but on website answer is 19 I don’t why can you help me why this happen?

During contest you didn’t help.but now why didn’t you write anything?there is no any problem in my computer 1 1 3 answer is 1 not -0 please check again.I submitted about 80 times but every time I got wrong answer just you compiler give -0.

If you are using gcc on a 64 bit linux system… dont forget to add the -m32 switch while compiling. That has troubled me a few times …

I dont use linux system.

Try this test
0 4 2 12
2 1 9 24
0 1 9 12
2 8 2 18
The correct answer is 12, while your answer is 28

1 Like

no my program give 12,I think there is some error in you compiler

This is useless discussion. Your code is compiler depended.
Try to download free GNU compiler and test you programs locally there.
Otherwise you will never get AC.

Moreover your program has TLE on some test cases.
You should reiterate your prime check routine.
It is too slow.
Why don’t you follow the editorial?
It contains pseudo-code blocks with explanation.
Why to be so obstinate?

I read editorial. in the editorial use 10^7 array and I used, use sieve algorithm and I used and if my program has TLE then editorial algorithm has TLE because I used the same algorithm.

From looking at your solution, the problem is that you are using uninitialized memory. You create sieve, but you need to set all values to true (except for 0 and 1, of course). Otherwise, your sieve will fail to find all primes.

1 Like

finally I found my mistake :slight_smile:

Congrats! So I close you question.