You are not logged in. Please login at to post your questions!


[closed] 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: 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?

asked 15 Jan '13, 17:31

shikimaru's gravatar image

accept rate: 0%

closed 17 Jan '13, 01:34

anton_lunyov's gravatar image

6★anton_lunyov ♦

The question has been closed for the following reason "The answer was figured it out by the user on his own." by anton_lunyov 17 Jan '13, 01:34

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


answered 15 Jan '13, 23:28

anton_lunyov's gravatar image

6★anton_lunyov ♦
accept rate: 12%

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

(15 Jan '13, 23:59) shikimaru3★

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.

(16 Jan '13, 14:45) anton_lunyov ♦6★

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?

(16 Jan '13, 14:49) anton_lunyov ♦6★

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.

(16 Jan '13, 15:42) shikimaru3★

finally I found my mistake :)

(16 Jan '13, 21:27) shikimaru3★

Congrats! So I close you question.

(17 Jan '13, 01:33) anton_lunyov ♦6★
showing 5 of 6 show all

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.


answered 16 Jan '13, 21:13

dr0b3rts's gravatar image

accept rate: 0%

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.


answered 15 Jan '13, 21:22

shikimaru's gravatar image

accept rate: 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 ..

(15 Jan '13, 21:27) cptcharisma3★

I dont use linux system.

(15 Jan '13, 21:52) shikimaru3★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 15 Jan '13, 17:31

question was seen: 765 times

last updated: 17 Jan '13, 01:34