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

WA!!! Help me! What is WRONG????
Posted by Michael Medvedev (KNU training center) 14 Nov 2002 00:06
HELP me - WA!!!
This is my program:


program p1222;
const LEN = 550;
type
  bigint = record
             mas:array[1..LEN] of byte;
             len:integer;
           end;
var
  t,i,n:integer;
  res:bigint;

procedure toone(var a:bigint);
var
  i:integer;
begin
  for i:=1 to LEN do a.mas[i]:=0;
  a.mas[1] := 1;
  a.len := 1;
end;

procedure mult(var res:bigint;i:integer);
var
  t,c,j:integer;
begin
  c := 0;
  for j:=1 to res.len do
  begin
    t := res.mas[j] * i + c;
    res.mas[j] := t mod 10;
    c := t div 10;
  end;
  if (c > 0) then
  begin
    Inc(j);
    res.mas[j] := c;
  end;
  res.len := j
end;

begin
  readln(n);
  if (n <= 4) then
  begin
    write(n);
    Exit;
  end;
  toone(res);
  if (n mod 3 = 1) then
  begin
    mult(res,4); n:= n - 4;
  end else
  if (n mod 3 = 2) then
  begin
    mult(res,2); n:= n - 2;
  end;
  t := n div 3;
  for i:=1 to t do
    mult(res,3);
  t := res.len;
  for i:=1 to t do
    write(res.mas[t-i+1]);
end.
I think there is a bug in tests.
Posted by Leo 20 Nov 2002 13:36
It's written, that n is a positive number, but I think, that there is
a test with n = 0 and it has answer 1. I don't know why, but with
"
if n = 0 then
begin
  WriteLn(1);
  exit
end;
"
it will work.(If you have not other bugs)
Re: I think there is a bug in tests.
Posted by Saber 14 Feb 2003 15:39
There is no bug in tests you only should find the correct algorithm
if you cant find mail me at : ssf_digi@hotmail.com
Re: I think there is a bug in tests.
Posted by .Net, Java - any pcode sucks 30 Apr 2007 22:24
you are wrong.

if (N < 3) Result = N;

this works successfully