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

Help with the WA!Thanks
Posted by Jordan 9 Mar 2002 15:11
Const St='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
Var Bit:Longint;
    P:Array[1..5000] Of Byte;
    S:String;
    k,a,b,c,d,e:Longint;
Begin
  Readln(S);
  Bit:=Length(S);
  For a:=1 to Bit Do
    P[a]:=Pos(S[bit+1-a],st)-1;
  iF s='0' tHEN
  Begin
    Writeln('No solution.');
    Halt;
  End;
  For K:=36 downto 2 Do
  Begin
    c:=1;D:=0;
    For b:=1 to Bit Do
    Begin
      D:=D+C*P[b];
      c:=C*k;
    End;
    If (D Mod (k-1))=0 Then
    Begin
      Writeln(K);
      Halt;
    End;
  End;
  Writeln('No solution.');
End.
Input file consists of one string containing no more than 10^6 digits or uppercase latin letters.
Posted by Lin 9 Mar 2002 16:45
> Const St='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
> Var Bit:Longint;
>     P:Array[1..5000] Of Byte;
>     S:String;
>     k,a,b,c,d,e:Longint;
> Begin
>   Readln(S);
>   Bit:=Length(S);
>   For a:=1 to Bit Do
>     P[a]:=Pos(S[bit+1-a],st)-1;
>   iF s='0' tHEN
>   Begin
>     Writeln('No solution.');
>     Halt;
>   End;
>   For K:=36 downto 2 Do
>   Begin
>     c:=1;D:=0;
>     For b:=1 to Bit Do
>     Begin
>       D:=D+C*P[b];
>       c:=C*k;
>     End;
>     If (D Mod (k-1))=0 Then
>     Begin
>       Writeln(K);
>       Halt;
>     End;
>   End;
>   Writeln('No solution.');
> End.