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

Especially to xyz(+) (Problem 1057
Posted by Michael_Rybak 6 Jan 2002 16:17
Please, help me! I've already posted this question, but nobody
answered. Why can't I get AC for this problem? I've already been sent
a correct solution, and I couldn't find a test for which our programs
give different results! Please, help me!

{$N+}
Program AB;
 Const Max=31;
 Var x,y,n:Extended;
     a:Array[0..32] Of Extended;
     cc:Array[0..Max,0..Max] Of Extended;
     mx,i,j,k,b:Longint;
 Function Fac(a:Longint):Extended;
  Var i:Longint;
      r:Extended;
 Begin
  r:=1;
  For i:=1 To a Do
   r:=r*i;
  Fac:=r;
 End;
 Function C(n,k:Longint):Extended;
  Var a:Extended;
 Begin
  If cc[n,k]>=0 Then
    c:=cc[n,k]
  Else Begin
   If k>n Then Begin
    cc[n,k]:=0;
    C:=0;
   End Else Begin
    If ((n=0) Or (k=0)) Then Begin
     cc[n,k]:=1;
     C:=1;
    End Else Begin
     cc[n,k]:=C(n-1,k)+C(n-1,k-1);
     C:=cc[n,k];
    End;
   End;
  End;
 End;
 Function f(x:Extended; k,mx:Longint):Extended;
  Var i:Longint;
      s:Extended;
 Begin
{  Writeln('x=',x:0:0,' k=',k); Readln;}
  If x=0 Then Begin
   If k=0 Then
    f:=1
   Else
    f:=0;
   Exit;
  End;
  s:=0;
  If k=1 Then Begin
   i:=-1;
   For i:=0 To mx-1 Do
    If a[i+1]>x Then
     Break;
   f:=i+1;
   Exit;
  End;
  For i:=0 To mx-1 Do
   If a[i+1]<=x Then Begin
    s:=s+C(i,k-1);
   End Else Begin
    s:=s+f(x-a[i],k-1,i);
    Break;
   End;
  f:=s;
 End;
Begin
{ Assign(input,'1057.in'); Reset(input);}
 For i:=0 To Max Do
  For j:=0 To Max Do
   cc[i,j]:=-1;
 For i:=0 To Max Do
  For j:=0 To Max Do
   c(i,j);
 Read(x,y,k,b);
 a[0]:=1;
 mx:=32;
 For i:=1 To 32 Do Begin
  a[i]:=a[i-1]*b;
  If a[i]>1E11 Then Begin
   mx:=i;
   Break;
  End;
 End;
 Writeln(f(y,k,mx)-f(x-1,k,mx):0:0);
End.
a little help
Posted by huyuan 6 Jan 2002 17:27
Have a look at your mail box.
Perhaps that will help you.
Good luck!