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

whi my program get CE? ENIBODY CAN HELP MEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Posted by I am david. Tabo. 12 Apr 2002 19:06
var ric,min,max,i,j,k,l,m,n: longint;
    a:array [1..1000] of longint;
begin
  readln (n,k);
  min:=1;
  i:=1;
  while i=n-1 do
    begin
      min:=min*10;
      inc (i);
    end;
  max:=k-1;
  j:=1;
  while j=n-1 do
    begin
      max:=max*10+(k-1);
      inc (j);
    end;
  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.
You have to learn a little Delphi, have a look at my comment :)
Posted by Vladimir Milenov Vasilev 13 Apr 2002 05:03
> var ric,min,max,i,j,k,l,m,n: longint;
>     a:array [1..1000] of longint;
> begin
>   readln (n,k);
>   min:=1;
>   i:=1;
>   while i=n-1 do
>     begin
>       min:=min*10;
>       inc (i);
>     end;
>   max:=k-1;
>   j:=1;
>   while j=n-1 do
>     begin
>       max:=max*10+(k-1);
>       inc (j);
>     end;
>   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;
  {HAve a look at my comment - here is your wrong!!!}
>       for j:=l downto 1 do
>         i:=i*10+a[j];
>       if (i mod 100)<>0 then
>         inc(m);
>     end;
>   writeln (m);
> end.
> Hei, the compiler in timus is Delphi - you can not change the value
of a variable, that controls the cicle, but in PAscal that i spossible
Where you have written "i=0", use another variable..I think, you will
get accepted.
Bye!
from Vlado