Cod sursa(job #42472)

Utilizator Bluedrop_demonPandia Gheorghe Bluedrop_demon Data 29 martie 2007 11:13:32
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.03 kb
{
    Problema cifra
}
Program cifra;

Var t, l, c, k, i, j, rez : Integer;
    s, s2 : string;

Begin
    Assign( input, 'cifra.in' );
    Reset( input );
        Readln( t );
    Assign( output, 'cifra.out' );
    Rewrite( output );
        While t > 0 do
            Begin
                t := t-1;
                readln( s );
                s2 := '';
                if length( s ) > 2 then s2 := s2+s[length(s)-1];
                s2 := s2+s[length(s)];
                val( s2, l, c );
                rez := 0;
                For i := 1 to l do
                    Begin
                        j := i;
                        k := i-1;
                        while k > 0 do
                            Begin
                                j := j*i mod 10;
                                k := k-1;
                            End;
                        rez := (rez + j ) mod 10;
                    End;
                Writeln( rez );
            End;
    Close( input );

    Close( output );
End.