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 1012. K-based Numbers. Version 2

I made a dimamic program, It should word, It worked for 1009
Posted by Nazgur ( Ivan Nicolae ) 21 Mar 2005 13:30
  My idea is simple:
  a[0]=1;
  a[1]=k-1;
  for i>=2 -> a[i]=(k-1)*a[i-1]+a[i-2];
  It should work.
  Here is my code:
  var n,k,i:longint;
    a,b,c:extended;

begin
     readln(n,k);
     a:=1;
     b:=k-1;
     for i:=2 to n do
        begin
             c:=(k-1)*(a+b);
             a:=b;
             b:=c;
         end;
     writeln(c:0:0);
end.
Re: I made a dimamic program, It should word, It worked for 1009
Posted by Cybernetics Team 23 Mar 2005 01:49
No, your 'dimamic program' shouldn't 'word' because you have to use big numbers...


Edited by author 23.03.2005 06:42