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

×

ChefHack WA. Please help.

I had almost the same solution as the one mentioned in the editorial, but I used Java and the sieve of atkin.

I tried several input cases, and they all generated the right answer on my computer. Yet I still got WA after submitting :/.

Could somebody tell me what's wrong?

http://www.codechef.com/viewsolution/1715077

asked 16 Jan '13, 02:23

kullalok's gravatar image

2★kullalok
1.5k112236
accept rate: 14%


You should avoid putting so much comments in your code... My advice is if you want to keep a large piece of code save it to a file or something like that... Just comment when you need to keep track of your current code, avoid keeping useless code comments, it just makes your life a lot harder.... Now back to your question: I would suggest you change your variable "ans" to type long... In some testcases the result will be a negative number because type int in this particular problem will not be enough to store all possible totals.... This is also mentioned in the Editorial in the first paragraph of "Quick Explanation". This seems to be the main reason for TLE on your code.

link

answered 16 Jan '13, 03:37

junior94's gravatar image

4★junior94
3.2k143058
accept rate: 15%

edited 16 Jan '13, 04:37

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×1,070
×22

question asked: 16 Jan '13, 02:23

question was seen: 607 times

last updated: 16 Jan '13, 04:37