• <input id="auww4"></input>
• <input id="auww4"><acronym id="auww4"></acronym></input>
• <input id="auww4"><u id="auww4"></u></input>
<object id="auww4"><acronym id="auww4"></acronym></object>
<input id="auww4"><u id="auww4"></u></input>
• F.A.Q
Hand In Hand
Online Acmers
Forum | Discuss
Statistical Charts
Problem Archive
Realtime Judge Status
Authors Ranklist

C/C++/Java Exams
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
Virtual Contests
DIY | Web-DIY beta
Recent Contests
Register new ID

<< Back to F.A.Q
Pascal programs are compiled on the server with Borland Delphi Compiler Version 15.0.
Q Are there any examples of solving a problem ?
A This is a sample solution for the A + B problem in Pascal:
var i, j : integer;
begin
while not eof do
begin
writeln(i + j);
end;
end.

Q What's new in the 32-bit compiler compared to the 16-bit one ?
A If you are used to writing programs for old 16-bit DOS compilers (for example, for Borland Pascal 7.0), then it would be useful for you to know the following:
• It is allowed to use arrays of size greater than 64 KB.
• The type integer is a 32-bit type and coincides with the type longint. The 16-bit signed integer type is called smallint.
• Strings can be longer than 255 characters. Don't refer to the zero character in order to determine the length of a string; use the function length(s) for this. You can set the length of a string using the procedure setlength(s, n).
Also, there are many new keywords. The following words cannot be redefined or used as identifiers:
and              array                as                asm
begin            case                 class             const
constructor      destructor           dispinterface     div
do               downto               else              end
except           exports              file              finalization
finally          for                  function          goto
if               implementation       in                inherited
initialization   inline               interface         is
label            library              mod               nil
not              object               of                or
out              packed               procedure         program
property         raise                record            repeat
resourcestring   set                  shl               shr
try              type                 unit              until
uses             var                  while             with
xor

In addition, the words protected and published are reserved within the description of an object. Also, the name result in the body of a function is reserved: the value of the corresponding variable is the result of the operation of the function, and a declaration of this name will lead to a compilation error. For example, the following definitions of functions are equivalent:
function Sum(a, b: integer): integer;
begin
Sum := a + b;
end;

function Sum(a, b: integer): integer;
begin
result := a + b;
end;

And this code will not be compiled:

function Sum(a, b: integer): integer;
var
result: integer;
begin
result := a + b;
Sum := result;
end;

Q What are the distinctions of the compiler as compared to other 32-bit Pascal compilers ?
A It is useful to know some features of the compiler used on the server.
• There are no modules crt and wincrt on the server because they contain procedures that are not needed for solving problems.
• Dynamic memory allocation involves rounding the size of a block to a multiple of 16 bytes. For example, if you allocate a lot of blocks 4 bytes each, then your program will use four times more memory than you really need. Use static data structures, which are free from this drawback and work faster than dynamic structures.
• Sets can occupy either 4 or 32 bytes, which also may lead to a significant memory overuse. In many cases a good alternative to sets is using bits of an integer (or of an array of integers).
• It is forbidden to convert explicitly the types of integer and floating-point variables. For example, the expression "x := extended(i)", where the type of x is extended, and i is integer, is incorrect, whereas the expression "x := i" is valid.
It is forbidden to change the value of the variable of a for loop inside the loop. The following code will not be compiled:
for i := 1 to 10 do
begin
if i mod 2 = 0 then inc(i);
writeln(i);
end;

Moreover, after a for loop the value of the loop variable is not defined. Therefore, this value cannot be used, for example, for a search. The following example will work differently with different compilers.
var
a: array[1..10] of integer;
i: integer;
begin
for i:=1 to 10 do
a[i] := i*i;
for i:=1 to 10 do
if a[i] = 17 then break;
writeln('i = ', i);
end.
{
Delphi output:      i = 11
FreePascal output:  i = 10
}

Q How to use 64-bit integer data types ?
A The compiler fully supports 64-bit integers (both signed and unsigned). A signed 64-bit integer ranges from ¨C9223372036854775808 to 9223372036854775807 and an unsigned 64-bit integer ranges from 0 to 18446744073709551615. The signed type is called int64, and the unsigned type is called qword. The following example illustrates the use of 64-bit integer types:
var
a: int64;
b: qword;
begin
writeln(a);
writeln(b);
end.

Q Any other notes ?
A Sometimes the Wrong Answer verdict actually means Runtime Error. This is because Delphi independently intercepts some runtime errors and sends a message to the output flow.

In order to increase the size of a stack and to avoid its overflow when using a ¡°deep¡± recursion, you should use a special directive (in the example, the size of the stack is set to be 16 MB):
{$M 16777216} It is convenient to use the conditional directive ONLINE_JUDGE for debugging solutions: var a, b: longint; begin {$IFNDEF ONLINE_JUDGE}
assign(input, 'input.txt');
reset(input);
assign(output, 'output.txt');
rewrite(output);
{$ENDIF} readln(a, b); writeln(a + b); {$IFNDEF ONLINE_JUDGE}
close(input);
close(output);
{\$ENDIF}
end.

This program will read data from the file input.txt on your computer and output the result to the file output.txt. On the server, it will use the standard input and output flows.