What wrong with Pascal compiler in UVA?

Write here if you have problems with your Pascal source code

Moderator: Board moderators

Post Reply
QulinXao
New poster
Posts: 29
Joined: Mon Apr 05, 2004 11:12 am

What wrong with Pascal compiler in UVA?

Post by QulinXao » Sat Jun 04, 2005 3:33 pm

here 2 solution for 10790 problem:
Cut after answer
they get same output BUT in UVA
sol1 AC & sol2 is WA ,
where I wrong? or Uva realy have strange bihavier?

PS. misof thank you!
Last edited by QulinXao on Sun Jun 05, 2005 9:53 pm, edited 1 time in total.

misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post by misof » Sat Jun 04, 2005 4:17 pm

The official documentation says:

"For Intel 80x86 processors, the comp type contains a 63-bit integral value, and a sign bit (in the MSB position). The comp type takes up 8 bytes of storage space. On other processors, the comp type is not supported."


On my machine [AMD Sempron, Linux, fpc 2.0.0rc2] both programs compile, but the second one sometimes gives slightly wrong answers. E.g. for the input

Code: Select all

19999 19999
0 0
it gives

Code: Select all

Case 1: 39988001299940000
(the correct answer is one greater). Apparently, comp got mapped to some floating-point type (probably double [8 bytes storage]) and its precision is not enough.

The extended data type corresponds to C/C++ long double [10 bytes] on the UVa machine

QulinXao
New poster
Posts: 29
Joined: Mon Apr 05, 2004 11:12 am

Post by QulinXao » Tue Mar 21, 2006 11:18 pm

here 2 solution(not full ) for 11014 problem:
sol1:
{$N+}const mn=100000;{100}
var r:array[0..mn] of comp;c12,t:comp;i,j,n:longint;
begin
{secret part 1-make all r[1..10000]}
i:=0;repeat read(n);if n=0 then break;
inc(i);n:=n div 2;writeln('Crystal ',i,': ',r[n]:0:0);
until false;
end.

sol2:
{$N+}const mn=100000;{100}
var r:array[0..mn] of int64;c12,t:int64;i,j,n:longint;
begin
{secret part 2-make all r[1..10000]}
i:=0;repeat read(n);if n=0 then break;
inc(i);n:=n div 2;writeln('Crystal ',i,': ',r[n]);
until false;
end.

where {secret part 1} {secret part 2} same
(i use comp cose prog under bp7(not have int64),(where all sizeof(array)<64K
I test sol for mn=100 then then send to uva with mn=100000;
)
in home both(sol1&sol2) compile by dcc32(ver 14.0) they get same output for all value 2,4,6..20000,0

but in uva (fpc)
sol1 WR & sol2 is AC ,
where I wrong? or Uva realy have strange bihavier?

PS. misof can you explain that new example?

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Tue Mar 21, 2006 11:40 pm

See my reply in Volume CX forum. I'm basicly saying the same as misof. In short: don't use Comp, it can give rounding errors. Use Int64 or QWord instead. Why don't you get yourself a copy of fpc? It's free and better than bp.
The biggest problem with most problems is not how to solve the problem, but how to not solve what is not the problem.

kwedeer
New poster
Posts: 44
Joined: Thu Dec 15, 2005 11:28 pm

Post by kwedeer » Fri May 19, 2006 3:41 pm

personally - I am using Delphi and and make code as console applications - I have received even some accepted - so - it works. Debugger and editor is nicier than fpc.

Post Reply

Return to “Pascal”