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 1014. Product of Digits

I've considered 0->10,but still got WA.Why?(program inside)
Posted by Sam Koo 25 Mar 2002 12:36
program u1014;

var
  n,u :longint;
  so :string;

begin
  readln(n);
  if n=0 then begin
    writeln('10');
    halt;
  end;
  so:='';
  u:=9;
  while n>9 do begin
    while (n mod u<>0) and (u>1) do dec(u);
    if u=1 then begin
      writeln('?');
      halt;
    end;
    so:=chr(48+u)+so;
    n:=n div u;
  end;
  so:=chr(48+n)+so;
  writeln(so);
end.
Try 20723
Posted by MadPsyentist/Sam 25 Mar 2002 13:00
> program u1014;
>
> var
>   n,u :longint;
>   so :string;
>
> begin
>   readln(n);
>   if n=0 then begin
>     writeln('10');
>     halt;
>   end;
>   so:='';
>   u:=9;
>   while n>9 do begin
>     while (n mod u<>0) and (u>1) do dec(u);
>     if u=1 then begin
>       writeln('?');
>       halt;
>     end;
>     so:=chr(48+u)+so;
>     n:=n div u;
>   end;
>   so:=chr(48+n)+so;
>   writeln(so);
> end.
>
Re: Try 20723
Posted by Pazzl 2 Apr 2002 00:17
W.A. Because in thy algorithm instead of "?" It is necessary to
remove "-1"
If that write on Zintel@inbox.ru