|
|
back to boardWhy WA? 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!!! 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! |
|
|