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

20 Lines AC
Posted by Bourne 12 Mar 2005 10:31
{k mod (k-1)=1}
  var
    a,min,k:shortint;
    t,i,tot:longint;
    x:char;
  begin
    min:=0; tot:=0;
    repeat
      read(x);
      if x in ['0'..'9']
        then a:=ord(x)-48
        else if x in ['A'..'Z']
               then a:=ord(x)-55;
      tot:=tot+a;
      if a>min then min:=a;
    until eoln;
    if min=0 then begin writeln(2); exit end;
    for k:=min+1 to 36 do
       if tot mod (k-1)=0 then begin writeln(k); exit end;
    writeln('No solution.');
  end.