ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1222. Chernobyl’ Eagles

Why WA?
Posted by Dmitry 'Diman_YES' Kovalioff 27 Oct 2002 16:39
It seems to me it is simple. Every count from 1 to 3000 is a sequence
3*3*3*...*2 or 3*3*3*...*3 or 3*3*3*...*4. Just long number
ariphmetics.
But Wrong Answer! Maybe my output is incorrect? Help me! Here is the
text of my program:

program DY_1222;
const
   ML=1000;
type
   TArray = array [1..ML] of integer;
var
   n,i1: longint;
   r: TArray;

{returns number of first non-zero position}
function GetStart(op: TArray): longint;
var
   prm: longint;
begin
   prm:=1;
   while op[prm]=0 do inc(prm);
   GetStart:=prm;
end;

{multiplies current array on 3}
procedure P(var op: TArray);
var
   prm: longint;
   mem: integer;
   buf: TArray;
begin
   mem:=0;
   FillChar(buf,SizeOf(buf),0);
   for prm:=ML downto GetStart(op) do
      begin
         buf[prm]:=(op[prm]*3+mem) mod 10;
         mem:=(op[prm]*3+mem) div 10;
      end;
   buf[prm-1]:=mem;
   op:=buf;
end;

begin
   Readln(n);
   if n>4 then
      begin
         r[ML]:=n-((n-2) div 3)*3;
         if r[ML]=0 then r[ML]:=1;
         for i1:=1 to (n-2) div 3 do P(r);
         for i1:=GetStart(r) to ML do Write(r[i1]);
      end
         else Write(n);
end.
I've got AC!!!
Posted by Dmitry 'Diman_YES' Kovalioff 28 Oct 2002 09:33
IMHO the ACM'system of checking is wrong. When I output my answer
as ...Write(r[i])...Write(r[i])... I receive WA, but when I output
may answer as ...Write(chr(ord(r[i])+48))...Write(chr(ord(r[i])
+48))... I receive AC. My problems with 1206 were the same. Admins,
check!