Phantom_Dreams's blog

By Phantom_Dreams, history, 3 months ago, In English

Say you wanted to calculate the floored square root of a number in C++, and you do: (int)sqrtl(x).

Or you wanted to calculate the floored base b logarithm of some number, and you do: (int)(logl(x)/logl(b)).

Could either of the 2 produce incorrect results due to precision errors?

I would assume since long double has 64 significant bits, both of the cases above should work correctly for all possible 64-bit integer values of x, but I am a bit skeptical of the logarithm, since there is an extra division step.

And if they are unreliable, what are good alternatives?

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By Phantom_Dreams, history, 3 months ago, In English

The whole point of your CF rating is to reflect your past performance in contests, which gives you a rough idea of how skilled you are as a competitive programmer.

So when your rating goes up significantly, it's usually a sign that you have improved significantly.

I would assume that people cheat for a better rating, but what is the point of increasing your rating if you know your skill hasn't increased alongside it?

It makes your rating feel meaningless... Completely removes the sense of accomplishment, which is the whole point of wanting to achieve a higher rating in the first place.

Full text and comments »

  • Vote: I like it
  • +32
  • Vote: I do not like it

By Phantom_Dreams, history, 3 months ago, In English

Why am I still gray?

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By Phantom_Dreams, history, 7 months ago, In English

Given $$$N$$$ integer intervals $$$[a, b]$$$, find the maximum number of pairs of overlapping intervals where each interval can belong to at most one pair.

Two intervals overlap if they share a common point, including closed endpoints.

The answer to the example above is 2. Pair the 2 black intervals and the 2 red intervals together.

What is the best time complexity that can be achieved for this problem? Currently I'm not sure if it's even solvable in polynomial time.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it