You are not logged in. Please login at 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?

asked 16 Jan '13, 02:23

kullalok's gravatar image

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.


answered 16 Jan '13, 03:37

junior94's gravatar image

accept rate: 15%

edited 16 Jan '13, 04:37

toggle preview

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: 16 Jan '13, 02:23

question was seen: 607 times

last updated: 16 Jan '13, 04:37