Notes for Microsoft Users

There are some places where the microsoft compiler is incorrect, and the judge's compiler will reject the incorrect programs that the microsoft compiler accepts. There are also some places where the standard does not specify any correct behaviour, and the microsoft compiler chooses a different rule than the judge's compiler.

We can not change the judge's compiler to accept things done the microsoft way without a lot of hacking that could make the whole thing fail. If you use a microsoft compiler you may have to make minor changes before submitting solutions for judging.

The judging system uses the Gnu C/C++ compiler for BSD unix systems. At the time of writing, the version is "gcc version 2.95.2 19991024 (release)".

Specific Points

Local declaration of control variablein a 'for' loop

This error is in the Microsoft C++ compiler version 6. Version 7 (.NET or 2003) seems to be fixed.

The microsoft compiler is wrong. The ISO C++ standard states that this example is correct:
        { for (int i=1; i<9; i+=1) x+=i;
          for (int i=1; i<9; i+=1) x*=i; }

But the microsoft compiler rejects it with an error message.
Conversely, the ISO C++ standard states that this example is incorrect:
        { for (int i=1; i<9; i+=1) x+=i;
          for (i=1; i<9; i+=1) x*=i; }

But the microsoft compiler accepts it.
As the microsoft compiler will not accept the correct version, we suggest that microsoft users convert such examples to:
        { int i;
          for (i=1; i<9; i+=1) x+=i;
          for (i=1; i<9; i+=1) x*=i; }

Which is a bit more long winded, but is both correct and accepted.

64-bit Integers

With the microsoft compilers, to declare then print a 64-bit int value, the following code is used:
        { __int64 x;
          x=1000001;
          x*=1000001;
          printf("x=%I64d\n", x); }

As the ISO C++ standard does not define correct behaviour for such values, this can not be called wrong. (Note that there are two underline characters in the type name). However, the judge's compiler uses a much more common (and rational) syntax:
        { long long int x;
          x=1000001;
          x*=1000001;
          printf("x=%qd\n", x); }

Whilst it would be possible to insert a macro defining __int64 to be long long int into the judging system, it is not possible to modify the behaviour of printf and scanf in a completely reliable and upgrade-proof way. Therefore micorsoft users have no alternative but to modify their programs before submission.