The problem is the following: http://www.spoj.com/problems/COLONY/
Well the logic seems pretty clear.My solution works for the given test cases and have checked upto year 10 for diff positions. It works.However it is still being shown as WA.
Any help is appreciated.
Code Removed
I didn't review the logic but noticed that you are storing the position as a double. The maximum position according to constraints is 2^51-1, which has 16 decimal digits, while double precision is only guaranteed up to 15 digits for some operations, see en.wikipedia.org/wiki/Double-pre ... int_format . So you could try changing the container and report back on whether that worked.
I had the same idea. But I think you should be aware that the fraction of double data type is specified to be 52 bits long, which might be sufficient here...
That's a good point, @daft_wullie. It was just a "let's rule this out" idea, since double makes things unnecessarily complicated here, in my view.
Now I've noticed that you have "1<<(i-1)", which will overflow int. You would want e.g. "1LL<<(i-1)".
@cyclopsthanks for the quick answerThe LL change worked and now its an AC
You may want to remove your code now...
You're welcome, and yes you should remove your code now.
Went into a no internet area for a while.Therefore the delay.