Page 1 of 1
What wrong with Pascal compiler in UVA?
Posted: Sat Jun 04, 2005 3:33 pm
by QulinXao
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!
Posted: Sat Jun 04, 2005 4:17 pm
by misof
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
it gives
(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
Posted: Tue Mar 21, 2006 11:18 pm
by QulinXao
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?
Posted: Tue Mar 21, 2006 11:40 pm
by little joey
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.
Posted: Fri May 19, 2006 3:41 pm
by kwedeer
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.