CHEFHACK compiler

chefhack

#1

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 ideone.com but in this site I get always wrong answer .for example in my computer give answer 20 which test case is:
1
3
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?


#2

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.


#3

Try this test
4
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


#4

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.


#5

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 …


#6

I dont use linux system.


#7

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


#8

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.


#9

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?


#10

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.


#11

finally I found my mistake :slight_smile:


#12

Congrats! So I close you question.