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?????????? help please!!!!!!!!!!!!!!!1
Posted by Oleg 27 Oct 2002 17:50
const max=1000;
var n2,j,i,k,n,l,n1:longint;
    a:array [1..1000] of longint;
    b:array [1..max] of longint;
begin
 readln(n);
 if n=0 then begin writeln(0); halt(0); end;
 n1:=1;
 a[n1]:=n;
 if n>1 then
 begin
  l:=0;
  while l=0 do
  begin
   i:=1;
   while i<=n1 do
   begin
    if (a[i] mod 2 =0) then
     if ((a[i] div 2)*(a[i] div 2)>a[i]) then
     begin
      inc(n1);
      a[n1]:=a[i] div 2;
      a[i]:=a[i] div 2;
      l:=1;
     end;
    if (a[i] mod 2 =1) then
     if ((a[i] div 2)*((a[i] div 2)+1)>a[i]) then
     begin
      inc(n1);
      a[n1]:=1+(a[i] div 2);
      a[i]:=a[i] div 2;
      l:=1;
     end;
    inc(i);
   end;
   l:=1-l;
  end;
 end;
 fillchar(b,sizeof(b),0);
 b[max]:=1;
 n2:=1;
 for i:=1 to n1 do
 begin
  for j:=max downto (max-n2) do b[j]:=b[j]*a[i];
  j:=max;
  while j>=(max-n2) do
  begin
   if (b[j]>9) then
   begin
    if j=n2 then
    begin
     inc(n2);
    end;
    b[j-1]:=b[j-1]+(b[j] div 10);
    b[j]:=(b[j] mod 10);
   end;
   dec(j);
  end;
 end;
 j:=1;
 while b[j]=0 do inc(j);
 for i:=j to max do write(b[i]);
 writeln;
end.
Re: Why WA?????????? help please!!!!!!!!!!!!!!!1
Posted by Dmitry 'Diman_YES' Kovalioff 27 Oct 2002 18:43
Your solution is wrong. For example, for input 8 it outputs 16, but
real answer is 18 (3*3*2). See my solution, but it is WA too :(