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

Why my program does not work?
Posted by I am david. Tabo. 31 Jan 2002 23:07
>Why my program get Compilation error?
>var ric,min,max,i,j,k,l,m,n: longint;
>    a:array [1..1000] of longint;
>begin
>  read (n,k);
>  min:=1;
>  for i:=1 to n-1 do
>    min:=min*10;
>  max:=k-1;
>  for i:=1 to n-1 do
>    max:=max*10+(k-1);
>  for i:=min to max do
>    begin
>      ric:=i;
>      l:=0;
>      while ric<>0 do
>        begin
>          inc (l);
>          a[l]:=(ric mod 10);
>          ric:=(ric div 10);
>        end;
>      for j:=1 to l do
>        if a[j]>k-1 then
>          begin
>            a[j]:=0;
>            inc (a[j+1]);
>          end;
>      i:=0;
>      for j:=l downto 1 do
>        i:=i*10+a[j];
>    if (i mod 100)<>0 then
>      inc(m);
>    end;
>  writeln (m);
>end.
Re: Why my program does not work?
Posted by Stupnikov Pavel 4 Feb 2002 18:34
> >Why my program get Compilation error?
> >var ric,min,max,i,j,k,l,m,n: longint;
> >    a:array [1..1000] of longint;
> >begin
> >  read (n,k);
> >  min:=1;
> >  for i:=1 to n-1 do
> >    min:=min*10;
> >  max:=k-1;
> >  for i:=1 to n-1 do
> >    max:=max*10+(k-1);
> >  for i:=min to max do
> >    begin
> >      ric:=i;
> >      l:=0;
> >      while ric<>0 do
> >        begin
> >          inc (l);
> >          a[l]:=(ric mod 10);
> >          ric:=(ric div 10);
> >        end;
> >      for j:=1 to l do
> >        if a[j]>k-1 then
> >          begin
> >            a[j]:=0;
> >            inc (a[j+1]);
> >          end;
> >      i:=0;
> >      for j:=l downto 1 do
> >        i:=i*10+a[j];
> >    if (i mod 100)<>0 then
> >      inc(m);
> >    end;
> >  writeln (m);
> >end.
>
1. warning: missing program header; (program my1009)
 GPC have not find anu other errors ...
2. You change i into for.
That's all. By ... Time Limit Exesteeded.