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 1009. K-based Numbers

Help please
Posted by Svyatoslav 16 Feb 2008 00:53
my code crashed on 1 test
{*****************}
type
integer=longint;
var
n,k:integer;
obr:string;
str:string;
otv:int64;

procedure p(s:string);
var
i,l:integer;
begin
 l:=length(s)-1;
 if l=n then
 begin
  inc(otv);
  writeln(s);
  exit;
 end;

 if l>n then
 begin
  exit;
 end;

 for i:=1 to k do
 begin
   if (s[l]='0')and(obr[i]='0') then continue;
   if (l=0)and(obr[i]='0') then continue;
   p(s+obr[i]);
 end;

end;

begin
assignfile(input,'in.txt');
reset(input);
assignfile(output,'out.txt');
rewrite(output);
readln(n);
readln(k);
otv:=0;
obr:='0123456789';
str:='_';
p(str);
writeln(otv);
end.
{*******************}
Please help!