Lord.of.AMC's blog

By Lord.of.AMC, 10 years ago, In English

I have the following code:

#include <iostream>
#include <vector>
using namespace std;
 
int v[2];
 
int main()
{
    double p;
    cin >> p;
    v[0] = p*10;
    cout << v[0] << endl;
}

When I input "2.3" into the program on my computer it gives the expected result, 23. But when I input 2.3 on Codeforces and run it, I get 22. Any reason why?

Full text and comments »

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

By Lord.of.AMC, 10 years ago, In English

**** Edit: it's fixed ****

On the contest page, it shows "Codeforces Round #247 (Div. 2)" twice, despite at two different times.

Full text and comments »

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

By Lord.of.AMC, 11 years ago, In English

A lot of solutions (including mine) for problem B failed on test 36, and the only languages that failed in this way were C and C++. I noticed this was because in C and C++, the size of a string is an unsigned integer. This is not the same in other languages, however. Hence, if we repeat from 0 to s.size()-3 we are really repeating from 0 to some huge integer. In the case of test #36, it is 4294967294 which caused many of us to RE. No other language would have this error. Thus, a lot of substantially correct solutions got rejected because of this small semantical problem.

Did any of you who use C/C++ know that this was coming? Any suggestions on how to avoid this problem in the future? Thanks for your help.

Full text and comments »

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

By Lord.of.AMC, 11 years ago, In English

It gets stuck on this screen forever:

http://prntscr.com/2l3ao5

Does anyone know what is the problem?

Full text and comments »

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