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 1104. Don’t Ask Woman about Her Age

Problem 1104
Posted by Anton 3 Sep 2001 22:23
Why I could not get Accepted?


var
  Ok:Boolean;
  C,T,Min,I:LongInt;
  Ch:Char;
begin
  C:=0;
  Ok:=False;
  while not Eof do begin
    Read(Ch);
    if Ch in['A'..'Z']then
      t:=10+Ord(Ch)-Ord('A');
    if Ch in['0'..'9']then
      t:=Ord(Ch)-Ord('0');
    if not(Ch in['0'..'9','A'..'Z'])then
      t:=0;
    if t>Min then
      Min:=t;
    C:=C+t;
  end;
  Inc(Min);
  if C=0 then begin
    Write(2);
    Halt(0);
  end;
  i:=Min;
  while(i<=36)and(not Ok)do begin
    if C mod(i-1)=0 then
      Ok:=True;
    Inc(i);
  end;
  if Ok then
    Write(i-1)
  else
    Write('No solution.');
end.
because yours write out a wrong output !
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 3 Sep 2001 22:52
> Why I could not get Accepted?
>
>
> var
>   Ok:Boolean;
>   C,T,Min,I:LongInt;
>   Ch:Char;
> begin
>   C:=0;
>   Ok:=False;
>   while not Eof do begin
>     Read(Ch);
>     if Ch in['A'..'Z']then
>       t:=10+Ord(Ch)-Ord('A');
>     if Ch in['0'..'9']then
>       t:=Ord(Ch)-Ord('0');
>     if not(Ch in['0'..'9','A'..'Z'])then
>       t:=0;
>     if t>Min then
>       Min:=t;
>     C:=C+t;
>   end;
>   Inc(Min);
>   if C=0 then begin
>     Write(2);
>     Halt(0);
>   end;
>   i:=Min;
>   while(i<=36)and(not Ok)do begin
>     if C mod(i-1)=0 then
>       Ok:=True;
>     Inc(i);
>   end;
>   if Ok then
>     Write(i-1)
>   else
>     Write('No solution.');
> end.