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 1223. Chernobyl’ Eagle on a Roof

why it is wrong?(+)
Posted by Test4 17 Nov 2002 06:32
Program chernobyl;
  var
    n,e,i:longint;
    t:array[1..1000] of longint;

function max(a,b:longint):longint;
  begin
    if a>b then max:=a else max:=b;
  end;

function fa(i,j:integer):longint;
  begin
    if i<=j then fa:=t[i]
      else if i=1 then fa:=1
             else if j=1 then fa:=i
                    else fa:=1+max(fa((i-1) shr 1,j-1),fa(i shr 1,j));
  end;

Begin
  for i:=1 to 1000 do t[i]:=trunc(ln(i)/ln(2))+1;
  readln(n,e);
  while n<>0 do
    begin
      writeln(fa(e,n));
      readln(n,e);
    end;
End.
Re: why it is wrong?(+)
Posted by Michael Medvedev (KNU training center) 19 Nov 2002 22:02
Your solution is wrong!

Try for k=2, n=10. The result must be 4, your solution gives 5.

If you can help me with 1222 (my WA solution is on a 1222 board), I
will help you with 1223.

Regards,
Michael
I can help you with 1222
Posted by Fechete Dan Ionut[dany] 20 Nov 2002 06:44
Each eagle sould have 3 or 2 heads especialy 3 so the product is
maximal
#include <stdio.h>
long int nr[2000];
int i,j,n,m,k;
void main()
{
scanf("%d",&n);
if (n<5) printf("%d",n);
 else
  {
  nr[0]=1;
  nr[1]=1;
  for (i=1;i<n/3;i++)
   {
      nr[1]*=3;
   for (j=2;j<=nr[0];j++)
    {nr[j]*=3;nr[j]+=nr[j-1]/10000;nr[j-1]%=10000;}
   if (nr[nr[0]]>9999)
    {
    nr[0]++;
    nr[nr[0]]=nr[nr[0]-1]/10000;
    nr[nr[0]-1]%=10000;
    }
   }
  if (n%3==0)
   {
   nr[1]*=3;
   for (j=2;j<=nr[0];j++)
    {nr[j]*=3;nr[j]+=nr[j-1]/10000;nr[j-1]%=10000;}
   if (nr[nr[0]]>9999)
    {
    nr[0]++;
    nr[nr[0]]=nr[nr[0]-1]/10000;
    nr[nr[0]-1]%=10000;
    }
   }
  if (n%3==1)
   {
      nr[1]*=4;
   for (j=2;j<=nr[0];j++)
    {nr[j]*=4;nr[j]+=nr[j-1]/10000;nr[j-1]%=10000;}
   if (nr[nr[0]]>9999)
    {
    nr[0]++;
    nr[nr[0]]=nr[nr[0]-1]/10000;
    nr[nr[0]-1]%=10000;
    }
   }
  if (n%3==2)
   {
      nr[1]*=6;
   for (j=2;j<=nr[0];j++)
    {nr[j]*=6;nr[j]+=nr[j-1]/10000;nr[j-1]%=10000;}
   if (nr[nr[0]]>9999)
    {
    nr[0]++;
    nr[nr[0]]=nr[nr[0]-1]/10000;
    nr[nr[0]-1]%=10000;
    }
   }
  printf("%d",nr[nr[0]]);
  for (i=nr[0]-1;i>0;i--)
   {
   printf("%d",(nr[i]/1000)%10);
   printf("%d",(nr[i]/100)%10);
   printf("%d",(nr[i]/10)%10);
   printf("%d",(nr[i]/1)%10);
   }
  }
}
Now you help me with 1223
I will help you with 1223 - send me your e-mail!
Posted by Michael Medvedev (KNU training center) 20 Nov 2002 23:13
PLEASE!
Never SUBMIT solutions to the WEBBOARD!!!

my email is medv@roller.ukma.kiev.ua
Send me your e-mail, and I will send you the 1223 solution!!!

Anyway, I knew the idea of solution for 1222, but I do not know
what's wrong in my program!!!

Thanks,
Michael
Re: I will help you with 1223 - send me your e-mail!
Posted by Oleg 21 Dec 2002 20:44
AC !!!!!!!!!!!!!!!!!!!!!!!!
Re: why it is wrong?(+)
Posted by Lovely girl 9 Mar 2005 05:17
Why it shows i am wrong at 2 100
my answer is 14 right is 16???
why??