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

Common Board

Why WrongAnswer on 1-st test(Task 1261)?
Posted by WuLF 5 Mar 2005 17:18
 Why I have WA on first test?



var s,i,n,j,k,l,z,x:longint;
    a:array[1..100] of longint;
begin
 readln(n);
 if n<=0 then
 begin
  halt;
 end;
 a[1]:=1;
 a[2]:=3;
 for i:=3 to 100 do
 begin
  a[i]:=a[i-1]*3;
  j:=j+1;
 end;
 l:=1;
 while l<>10000 do
 begin
  s:=a[l];
  if s>=n then
  begin
   k:=s;
   if k=n then
   begin
    writeln('0');
    halt;
   end
   else
   begin
    s:=s-n;
    break;
   end;
  end;
  l:=l+1;
 end;
 writeln(k,' ',s);
readln;
end.