R.A.X's blog

By R.A.X, 10 years ago, In English

The below mentioned code is giving random answer on submission on codeforces, but on my local maschine it is giving correct answer. I am using the following g++ version gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) and compiling using the command g++ -g -std=c++0x d.cpp code

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By R.A.X, 10 years ago, In English

I am implementing a simple binary search.But my program is not giving the correct solution on some values. long long low=1,high=100000000000000,mid=0,ans=0;
while ( high > low)
{
mid =low +(high-low)/2;
ans=mid;
if( ans==m )
return ans;
if (ans > m)
high=mid-1;
else
low=mid+1;
} return low;

This binary search should return the value equal to m,But this is failing on most of the cases. Can anyone tell me the mistake??

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it

By R.A.X, 10 years ago, In English

I am stuck on this problem http://www.spoj.com/problems/MINUS/ and after searching the topcoder forum http://apps.topcoder.com/forums/?module=Thread&threadID=699255&start=0&mc=11#1336125 I can tell whether sum m(given in problem) can be formed or not,But I am not getting How to find which i to choose first for performing operations?? Any help will be appreciated!

Full text and comments »

Tags spoj, dp
  • Vote: I like it
  • -6
  • Vote: I do not like it

By R.A.X, 10 years ago, In English

I am unable to solve this problem http://codeforces.me/contest/441/problem/E .Can you guys provide me with some hints?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it