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!
What wrong with Pascal compiler in UVA?
Moderator: Board moderators
What wrong with Pascal compiler in UVA?
Last edited by QulinXao on Sun Jun 05, 2005 9:53 pm, edited 1 time in total.
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
"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
Code: Select all
Case 1: 39988001299940000
The extended data type corresponds to C/C++ long double [10 bytes] on the UVa machine
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?
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?
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 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.